0

我是 geodjango 的新手,当我在地图上找到我的位置时,我正在使用传单在模板上显示地图,它显示了距离该点几米的位置,但我需要真正的位置任何帮助

// placeholders for the L.marker and L.circle representing user's current position and accuracy    
        var current_position, current_accuracy;

        function onLocationFound(e) {
          // if position defined, then remove the existing position marker and accuracy circle from the map
          if (current_position) {
              map.removeLayer(current_position);
              map.removeLayer(current_accuracy);
          }
    
          var radius = e.accuracy / 2;
    
          current_position = L.marker(e.latlng).addTo(map)
            .bindPopup("You are within " + radius + " meters from this point, Lt: "+e.latlng).openPopup();
    
          current_accuracy = L.circle(e.latlng, radius).addTo(map);
        }
    
        function onLocationError(e) {
          alert(e.message);
        }
    
        map.on('locationfound', onLocationFound);
        map.on('locationerror', onLocationError);
    
        // wrap map.locate in a function    
        function locate() {
          map.locate({setView: true, maxZoom: 16});
        }
    
        // call locate every 3 seconds... forever
        setInterval(locate, 3000);

这是截图 在此处输入图像描述

4

0 回答 0