2014-02-13 100 views
-2

我有一个谷歌地图上有一个标记和一个圆圈,标记工作正常,但圆圈没有出现。谷歌地图 - 圆圈没有出现

我盯着代码,比较了一堆类似的东西,但在我的生活中,我看不到我要去哪里错了。

任何人都可以帮我吗?

function initialize() { 
    var userLocation = "London"; 
    var geocoder = new google.maps.Geocoder(); 
    var circle; 
    var styles = [ 
        { 
        stylers: [ 
         { hue: "#00ffe6" }, 
         { saturation: -20 } 
        ] 
        } 
       ]; 
    geocoder.geocode({"address": userLocation}, function(results, status) { 
     if (status == google.maps.GeocoderStatus.OK) { 

      var latLng = results[0].geometry.location; 
      //alert (latLng); 
      var mapOptions = { 
       center: latLng, 
       zoom: 6, 
       styles: styles, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 
      map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); 
      var marker = new google.maps.Marker({ 
       map: map, 
       position: results[0].geometry.location, 
       draggable: true 
      }); 
      var circle = new google.maps.Circle({ 
       map: map, 
       radius: 50000, //your radius in meters 
       fillColor: "#000000", 
       center: point 
      }); 
      $("#ListingGeolocation").val(results[0].geometry.location); 
      google.maps.event.addListener(marker, "dragend", function(){ 
       var position = marker.getPosition(); 
       map.setCenter(position); 
       $("#ListingGeolocation").val(position.lat() + " ," + position.lng()); 
      }); 
     } else { 
      alert("Geocode failed. Please edit your address (top of the page) and try again."); 
     } 
    }); 
} 
    google.maps.event.addDomListener(window, "load", initialize); 

编辑

我试图从上面的代码为我中心伸出的经纬度变量,但就像你已经设置的位置也没有工作

var latLng = results[0].geometry.location; 
+2

你的圈子的中心不应该是点,它应该是latlng,对吧? – user2930100

+0

我把它改为建议的拉特兰 - 见编辑瞿 - 没有工作寿:( –

+0

这很奇怪[它对我很好](http://jsfiddle.net/n6p54/1/) – geocodezip

回答

1

它看起来并不为圆。

也许尝试更改center: pointcenter: new google.maps.LatLng(YOURLAT, YOUR LONG)作为测试。

+0

对不起 - 我会编辑我的曲 –