2015-07-02 27 views
0

我畫了一個圓和一些使用addGeoJson的多邊形。問題是一些多邊形被畫在圓上面,一些在下面。如何解決這個問題?我想繪製所有多邊形頂部的圓。這裏是我的代碼如何解決谷歌地圖Z指數問題

var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()); 
var mapOptions = { 
    zoom:9, 
    center:latlng, 
    mapTypeId:google.maps.MapTypeId.ROADMAP 
}; 
map1 = new google.maps.Map(mapcontainer, mapOptions); 


var circleOptions = { 
    fillOpacity:0, 
    strokeColor: '#000000', 
    strokeWeight:2, 
    strokeOpacity:1, 
    center:map1.getCenter(), 
    radius:2000, 
    map:map1 
}; 

circleRadius = new google.maps.Circle(); 
circleRadius.setOptions(circleOptions); 

var listOfPolygons = loadPolygons(); 

//drawing polygon layers 
var layer = new google.maps.Data(); 
var url = 'url/to/cords'; 
$.ajax({ 
    url: url, 
    type: 'POST', 
    data: {'codes': listOfPolygons}, 
    success:function(data) { 
     layer.addGeoJson(data); 
     layer.setMap(map1); 
     layer.setStyle({ 
      strokeColor: '#6da57a', 
      strokeOpacity:.4, 
      strokeWeight:1, 
      fillColor: '#7bd490', 
      fillOpacity:.6 
     }); 
    } 
}); 

見截圖 enter image description here

+0

你能提供樣品多邊形(和其它數據)複製(以問題的[最小的,完整的,經過測試和讀示例](http://stackoverflow.com/help/mcve))的問題 – geocodezip

+0

爲什麼負面?這個問題有什麼不對?看到黑色的圓形線,位於它下面的多邊形上方的某處。 – coure2011

回答

1

只需設定zIndex -options並給圈高zIndex的比數據的功能。

var circleOptions = { 
    fillOpacity:0, 
    strokeColor: '#000000', 
    strokeWeight:2, 
    strokeOpacity:1, 
    center:map1.getCenter(), 
    radius:2000, 
    map:map1, 
    zIndex:1//<----here 
}; 

//........ 


layer.setStyle({ 
     strokeColor: '#6da57a', 
     strokeOpacity:.4, 
     strokeWeight:1, 
     fillColor: '#7bd490', 
     fillOpacity:.6, 
     zIndex:0//<-----here 
    });