本文介绍了地理编码谷歌地图错误的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图在简单地图示例()和标记从不停留在正确的地方。在Google地图中,我总是会得到两个标记,一个是红色标记(标记街道),另一个是绿色标记(箭头标记正确的位置),就像这张照片



怎么可以我解决了这个问题?

解决方案

如果你知道标记所在的位置(坐标),不要使用地理编码器,只要把你想要它的标记。像一样b $ b请注意,您发布的示例使用的是Google Maps API v2,并于2010年5月19日弃用;并且会在2013年5月19日到期。不鼓励使用该版本的新开发。

 <!DOCTYPE html> 
< html>
< head>
< meta name =viewportcontent =initial-scale = 1.0,user-scalable = no>
< meta charset =utf-8>
< title> Google Maps JavaScript API v3示例:Marker Simple< / title>
< script src =https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false>< / script>
< script>
函数initialize(){
var myLatlng = new google.maps.LatLng(-23.426056,-47.599556);
var mapOptions = {
zoom:4,
center:myLatlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

var marker = new google.maps.Marker({
position:myLatlng,
map:map,
title:'Hello World!'
});
}
< / script>
< / head>
< body onload =initialize()>
< div id =map-canvasstyle =height:400px; width:500px;>< / div>
< / body>
< / html>


i'm trying to put an marker in the position ( -23.426056, -47.599556 ) in the Simple Map Example (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html) and the marker never stay in the right place. In Google Maps I always get two markers, a red one(that marks the street) and the green one(an arrow that marks the right th exact place) like in this photo http://s4.postimg.org/6ahyt0rm5/ibagen.gif

how can i solve this?

解决方案

If you know where the marker belongs (the coordinates), don't use the geocoder, just put the marker where you want it. Like this example from the Google Maps API v3 documentationNote that the example in you post is using the Google Maps API v2, whih was deprecated May 19, 2010; and reaches end of life May 19, 2013. New development using that version is discouraged.

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Google Maps JavaScript API v3 Example: Marker Simple</title>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
      function initialize() {
        var myLatlng = new google.maps.LatLng(-23.426056, -47.599556);
        var mapOptions = {
          zoom: 4,
          center: myLatlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: 'Hello World!'
        });
      }
    </script>
  </head>
  <body onload="initialize()">
    <div id="map-canvas" style="height:400px; width:500px;"></div>
  </body>
</html>

这篇关于地理编码谷歌地图错误的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:08