|

楼主 |
发表于 2017-7-18 16:18:14
|
显示全部楼层
本帖最后由 不老刘 于 2017-7-18 16:32 编辑
这是百度官网的浏览器定位demo,放到.w文件里用apploader 跑就定位不准了。百度这个demo放到.html页面里定位就正常。
把.html页面通过iframe方式引入到.w文件里跑也正常,就是这样直接用不行,定位有偏差!!
经纬度分别偏差 0.011957 和 0.00717
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
- var that=null;
- var Model = function(){
- this.callParent();
- that = this;
- };
-
- Model.prototype.modelLoad = function(event) {
- this.loadBaiduMap();
- };
- Model.prototype.loadBaiduMap = function() {
- var id = this.getIDByXID("baiduMap");
- window._baiduInit = function() {
- var map = new BMap.Map(id);
-
- var point = new BMap.Point(116.331398,39.897445);
- map.centerAndZoom(point,12);
- var geolocation = new BMap.Geolocation();
- geolocation.getCurrentPosition(function(r){
- if(this.getStatus() == BMAP_STATUS_SUCCESS){
- var mk = new BMap.Marker(r.point);
- map.addOverlay(mk);
- map.panTo(r.point);
- console.log('您的位置:'+r.point.lng+','+r.point.lat);
- }
- else {
- alert('failed'+this.getStatus());
- }
- },{enableHighAccuracy: true})
- }
- require([ 'http://api.map.baidu.com/api?v=2.0&ak=您的密钥&callback=_baiduInit' ], function() {
- if (!(window.BMap && window.BMap.apiLoad)){
- window._baiduInit();
- }
- });
- };
- return Model;
- });
复制代码
求教!!
|
|