|
我的应用需要展现地图,打包运行后,地图显示不出来。apploader中显示是正常的,由于环境不同,代码是在apploader中完整抄过去的。
实际代码为:
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
- require("cordova!cordova-plugin-geolocation");
- require("cordova!com.justep.cordova.plugin.baidulocation");
- require("cordova!com.justep.cordova.plugin.baiduMapBase");
- require("cordova!com.justep.cordova.plugin.baiduMapSearch");
- var Model = function(){
- this.callParent();
- this._lon ;
- this._lat ;
- };
- Model.prototype.modelParamsReceive = function(event){
- //百度地图显示
- var my = this ;
- //打开地图
- var lat = event.data.lat ;
- var lon = event.data.lon ;
- alert(lat) ;
- navigator.baiduMap.base.open({
- "position":{x:0, y:48, w:$(window).width(), h:$(window).height()-48},
- //"position":{x:0, y:$(window).height()-300-50, w:$(window).width(), h:300}, //成功
- //"position":{x:0, y:$(window).height(), w:$(window).width(), h:$(window).height()},
- //"center":{lon:my._lon, lat:my._lat},
- "center":{lon:lon, lat:lat},
- "zoomLevel":15,
- "events":{"click":onClick,"dbClick":ondbClick,"longPress":onLongPress}
- }, function(){
- justep.Util.hint("成功");
- }, callBack);
- };
- var onClick = function(event,args){
- justep.Util.hint(JSON.stringify(args));
- };
- var ondbClick = function(event,args){
- justep.Util.hint(JSON.stringify(args));
- };
- var onLongPress = function(event,args){
- justep.Util.hint(JSON.stringify(args));
- };
- var callBack = function(info){
- console.log(JSON.stringify(info));
- justep.Util.hint(JSON.stringify(info));
- };
-
- Model.prototype.button1Click = function(event){
- //显示当前位置
- navigator.baiduMap.base.showCurrentLocation({
- isShow:true,
- trackingMode:"none"
- });
- };
-
- Model.prototype.button2Click = function(event){
- //添加大头针
- navigator.baiduMap.base.addAnnotations([{
- id:1,
- title:"盐城市政府",
- //subTitle:"张三",
- lon:120.1688153093,
- lat:33.3543605899,
- draggable:true,
- color:navigator.baiduMap.base.annotationColor.Red
- },{
- id:2,
- title:"创投中心",
- //subTitle:"李四",
- lon:120.1730808076,
- lat:33.3527067751,
- draggable:false,
- color:navigator.baiduMap.base.annotationColor.Purple
- },{
- id:3,
- title:"科技馆",
- //subTitle:"王五",
- lon:120.1743008076,
- lat:33.3514367751,
- draggable:false,
- color:navigator.baiduMap.base.annotationColor.Green
- }], callBack, callBack);
- };
-
- Model.prototype.backBtnClick = function(event){
- navigator.baiduMap.base.close();
- this.close() ;
- };
-
- return Model;
- });
复制代码
请老师指导一下,我的错误在哪里?
非常感谢!
|
|