How to place multiple icons for Google map markers in v3?

后端 未结 3 2005
别那么骄傲
别那么骄傲 2021-01-19 18:34

I\'m trying to create a map similar to this (which is using v2 of the API). I want each marker on the map to consist of an image with a frame or background behind like so.

3条回答
  •  萌比男神i
    2021-01-19 19:13

    I think you'll have to merge the images with the marker backgrounds. When I was building something similar I used CSS sprites and calculated the vertical offset (vPos), based on a standard height. I just didn't bother with the shadows.

         var mImage = new google.maps.MarkerImage("YOURMARKER.png", 
            new google.maps.Size(34, 35), 
            new google.maps.Point(0, vPos),
            new google.maps.Point(10, 34)
        ); 
        //insert marker
        marker = new google.maps.Marker({
            icon: mImage,
            position: new google.maps.LatLng(latitude, longitude),
            map: map
        });
    

提交回复
热议问题