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");
                    }
                });
            }
            });
  • 相关阅读:
    Generator函数介绍
    C语言基础三
    C语言基础二
    C语言基础一
    node——路由控制
    Node.js_HTTP模块
    node_Express安装及检验
    conda Pyhon版本切换
    JAVA泛型里面各值代表的意义
    jq实现表格多行列复制
  • 原文地址:https://www.cnblogs.com/ccllj/p/9638016.html
Copyright © 2011-2022 走看看