我想像这样包装一个javascript代码:
map.addMarker({
lat: -12.043333,
lng: -77.028333,
draggable: true,
fences: [polygon],
outside: function(m, f){
alert('This marker has been moved outside of its fence');
}
});
下面是我如何用 Java 编写它:
@JsType(namespace = JsPackage.GLOBAL, isNative = true, name = "Object")
public class MarkerOptions {
@JsProperty
public double lat;
@JsProperty
public double lng;
@JsProperty
public boolean draggable;
@JsProperty
public Polygon fences;
@JsFunction
public interface FunctionOutsideParam {
void outside();
}
@JsProperty
public FunctionOutsideParam outside;
}
但它不起作用。即使你在我的浏览器控制台中也没有任何错误。有人知道如何使它适用于外部回调函数吗?谢谢并恭祝安康。