2013-08-27 69 views
1

在谷歌地圖文檔(https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions)它說:陰影谷歌地圖visualRefresh

「當google.maps.visualRefresh設置爲true陰影不會呈現。」

是否有可能覆蓋這個並使用visualRefresh獲得陰影顯示?

我還發現了文檔,說明此(https://devsite.googleplex.com/maps/documentation/javascript/basics):

所有的陰影都在視覺刷新被刪除。任何以編程方式指定的陰影都將被忽略。

它仍然看起來很奇怪,我認爲他們不會讓你以某種方式覆蓋此,讓陰影和visualRefresh,如果是這樣的話

回答

3

您可以創建帶有陰影的標記圖標。

或者爲包含陰影的標記(即不是google.maps.Marker對象)製作自定義疊加層。

proof of concept,從我的回答相關問題:Marker shadows in Google Maps v3

現在是更多的工作,但還是有可能的,因爲它不再是默認行爲。

+0

這偉大的工作,我只是用自定義疊加產生的陰影。謝謝! –

+0

如果您將陰影添加到標記圖像中,它們最終會被塗在具有較低z-索引的標記上,這看起來是錯誤的。 – johncip

0

爲什麼不創建一個具有較低z-index的額外標記?它比創建自定義疊加層的工作量更少,可以說是更正確的方法。 (如果您創建的影子爲所建議的圖標圖像的一部分,一個標記圖標,影子也可點擊,這是不可取的)

createMarkerShadow = function(map, data) { 
     var latLng = new google.maps.LatLng(data.latitude, data.longitude); 
     var markerShadow = new google.maps.Marker({ 
      clickable: false, 
      position: latLng, 
      map: map, 
      icon:{ 
       url: '/frontend/img/icons/google-map-marker-shadow.svg', 
       //The size image file. 
       size: new google.maps.Size(225, 120), 
       //The point on the image to measure the anchor from. 0, 0 is the top left. 
       origin: new google.maps.Point(0, 0), 
       //The x y coordinates of the anchor point on the marker. e.g. If your map marker was a drawing pin then the anchor would be the tip of the pin. 
       anchor: new google.maps.Point(115, 82) 
      }, 
      zIndex: (Math.round(latLng.lat()*-100000)<<5)-1 
     }); 

     return markerShadow; 
    }; 


setMarkerShadows = function (map, locations, bound) { 
    for (var i = 0; i < locations.length; i++) { 
     var data = locations[i]; 
     var markerShadow = createMarkerShadow(map, data); 

     bound.extend(markerShadow.getPosition()); 
    } 
}; 

bound = new google.maps.LatLngBounds();