uni.onLocationChange在断网情况下也失效,打算写原生插件来显示用户当前位置,但是不知道怎么能获取到页面上的mapView
<map id="map" class="map" :longitude="lon" :latitude="lat" :enable-traffic="true" :show-location="true" :markers="markers" :polyline="polyline" :polygons="polygons"></map>
@UniJSMethod(uiThread = true)
public void setLocationPoint (MapView mapView, UniJSCallback callback){
JSONObject data = new JSONObject();
try {
AMap aMap = mapView.getMap(); //这里的mapView不知道怎么获取到,或者有没有别的途径获取到aMap对象????
MyLocationStyle myLocationStyle = new MyLocationStyle();
myLocationStyle.interval(2000);
aMap.setMyLocationStyle(myLocationStyle);
data.put("code", 200);
data.put("data", "success");
}catch (Exception e){
data.put("code", 500);
data.put("data", e);
}
callback.invoke(data);
}
1 个回复
FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
我做过很多基于<map>扩展的原生插件,有需要有偿支援,可以联系我