zoukankan      html  css  js  c++  java
  • plus maps实时定位

    .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");
                    }
                });
            }
            });
  • 相关阅读:
    群资料共享
    python 智能合约日志操作
    canvas绘制图片
    rgb随机变色
    直接用css生成三角形的问题
    纯css三层侧边栏效果
    清除浮动终极版本
    懒加载
    html5可以通用的几段代码
    jquery中animate()动画方法
  • 原文地址:https://www.cnblogs.com/ccllj/p/9638016.html
Copyright © 2011-2022 走看看