1

In the Google Maps docs (https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions) it says:

"Shadows are not rendered when google.maps.visualRefresh is set to true."

Is it possible to overwrite this and get the shadows to show up while using the visualRefresh?

I have also found the docs stating this (https://devsite.googleplex.com/maps/documentation/javascript/basics):

All shadows have been removed in the visual refresh. Any shadows specified programmatically will be ignored.

It still seems odd to me that they wouldn't allow you to somehow overwrite this to allow shadows AND the visualRefresh, if that's the case.

Chris Morgan
  • 86,207
  • 24
  • 208
  • 215
Zach Reed
  • 683
  • 2
  • 9
  • 25

2 Answers2

4

You can create your marker icon with a shadow.

Or make a custom overlay for your markers which includes a shadow (i.e. not the google.maps.Marker object).

proof of concept, from my answer to the related question: Marker shadows in Google Maps v3

It is now more work, but still possible, as it is no longer the default behavior.

Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245
0

Why not create an extra marker with lower z-index? It's less work than creating a custom overlay, and arguably a more correct way to do it. (if you create one marker icon with shadow as part of the icon image as suggested, the shadow is also clickable, and that's not desirable)

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();