1

在谷歌地图文档(https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions)它说:

“当 google.maps.visualRefresh 设置为 true 时,不会呈现阴影。”

是否可以覆盖它并在使用visualRefresh时显示阴影?

我还找到了说明这一点的文档(https://devsite.googleplex.com/maps/documentation/javascript/basics):

视觉刷新中所有阴影都已删除。任何以编程方式指定的阴影都将被忽略。

在我看来,他们不允许你以某种方式覆盖它以允许阴影和视觉刷新,如果是这样的话,这对我来说仍然很奇怪。

4

2 回答 2

4

您可以创建带有阴影的标记图标。

或者为包含阴影的标记(即不是 google.maps.Marker 对象)制作自定义叠加层。

概念证明,来自我对相关问题的回答:Google Maps v3 中的标记阴影

现在需要做更多的工作,但仍有可能,因为它不再是默认行为。

于 2013-08-27T16:00:47.583 回答
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();
于 2015-02-04T11:00:39.853 回答