首页 > 其他 > 详细

plus maps实时定位

时间:2018-09-12 23:20:42      阅读:178      评论:0      收藏:0      [点我收藏+]
.mapContent {
                position: absolute;
                top: 44px;
                left: 0;
                right: 0;
                bottom: 0;
            }
 <div id="content" class="mapContent"></div>
mui.plusReady(function() {
            var count = 0;
            var marker;
            var map = new plus.maps.Map("content");
            setTimeout(function() {
                userlocation();
            }, 1);
            
            function userlocation() {
            //    alert("18")
            map.getUserLocation(function(state, pos) {
                count++;
                if(0 == state) {

                    if(count == 1) {

                        setTimeout(function() {

                            map.setZoom(17);
                            map.removeOverlay(marker);
                            marker = new plus.maps.Marker(pos);
                            marker.setIcon("img/icon_location@2x.png");
                            map.addOverlay(marker);
                        }, 400);
                        map.setCenter(pos);
                        setTimeout(function(e) {

                            userlocation();
                        }, 200);
                    } else {

                        map.removeOverlay(marker);
                        //                            map.setCenter(pos);
                        marker = new plus.maps.Marker(pos);
                        marker.setIcon("img/icon_location@2x.png");
                        map.addOverlay(marker);

                        setTimeout(function(e) {
                            //    alert("18-1-2-1")
                            userlocation();
                        }, 5000);

                    }
                } else {
                    //alert("18-2")
                    alert("xxx");
                }
            });
        }
        });

 

plus maps实时定位

原文:https://www.cnblogs.com/ccllj/p/9638016.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!