Marker shadows in Google Maps v3

前端 未结 2 1005
傲寒
傲寒 2020-12-12 05:33

I\'m looking for a way to make marker shadows work with the \"visual refresh\" that\'s coming to Google Maps, but can\'t seem to.

I suppose the following is the reco

2条回答
  •  臣服心动
    2020-12-12 06:09

    Why not create an extra marker with lower 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();
    

提交回复
热议问题