码迷,mamicode.com
首页 > 其他好文 > 详细

plus maps实时定位

时间:2018-09-13 00:02:47      阅读:645      评论:0      收藏:0      [点我收藏+]

标签:class   ready   read   fun   oom   png   content   pre   out   

.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实时定位

标签:class   ready   read   fun   oom   png   content   pre   out   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!