C
C
Cheizer2018-07-10 12:58:59
Google
Cheizer, 2018-07-10 12:58:59

Google Maps Api how to set several markers on the map with the MarkerImage parameter?

Friends, please tell me how to add several markers to the map in the Google Maps API when using your MarkerImage marker image, there are many examples on the Internet for a regular marker, but with MarkerImage, and even with a similar map initialization, I could not find anything sensible, I appeal to you for help, help!

Here I raised my example of a map https://codepen.io/Cheizer/pen/xJxRvY

I initialize the map from the file connected to the main page like this

function initialize() {  
   
    var secheltLoc = new google.maps.LatLng(55.70974356900742,37.61691650000001);
    var marcercenter = new google.maps.LatLng(55.70974356900742,37.61691650000001); 
          
                var myMapOptions = {
                    center: secheltLoc,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    zoom: 15,
                    scrollwheel: false,
                    mapTypeControl: false,
                    zoomControl: true,
                    styles: [{}]
                };
                var theMap = new google.maps.Map(document.getElementById("map"), myMapOptions);

                var image = new google.maps.MarkerImage(
                    'http://young-media.ru/images/map-marker.png',
                    new google.maps.Size(128, 128),
                    new google.maps.Point(0, 0),
                    new google.maps.Point(65, 65)
                );
               
                var marker = new google.maps.Marker({
                    map: theMap,
                    icon: image,
                    draggable: false,
                    animation: google.maps.Animation.DROP,
                    position: marcercenter,
                    visible: true
                });

            }

            google.maps.event.addDomListener(window, 'load', initialize);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question