|
本帖最后由 cxkj103 于 2017-9-4 10:01 编辑
想利用百度定位,实现获取地名。在apploader 中运行正常。但打包后闪退。不知道是什么原因?
require("cordova!cordova-plugin-geolocation");
require("cordova!cordova-plugin-compat");
require("cordova!com.justep.cordova.plugin.baiduMapBase");
require("cordova!com.justep.cordova.plugin.baiduMapSearch");
var callBack = function(info){
alert("信息");
};
Model.prototype.button2Click = function(event){
var me = this;
function onSuccess(position) {
alert('经度: ' +position.coords.longitude);
me.getNameByCoor(position.coords.longitude,position.coords.latitude);
}
function onError() {
me.comp("output1").set({value:"定位失败"});
alert("定位失败");
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
};
Model.prototype.getNameByCoor = function(la,lb){
navigator.baiduMap.base.getNameFromLocation({
lon:la,
lat:lb,
mcode:"cn.cxkj.zx"
}, callBack, callBack);
};
|
|