Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Sunday, August 14, 2016

How to change icon on Google map marker

How to change icon on Google map marker


I want to use my customize icon on Google map, and added icon url on the code. But it's still not reflecting on the map. Can anyone suggest, what i am missing here. Why icon is not changing, after adding the icon url "http://google-maps-icons.googlecode.com/files/sailboat-tourism.png".

            

Answer by EdenSource for How to change icon on Google map marker


You have to add the targeted map :

var markers = [              {              "title": 'This is title',              "lat": '-37.801578',              "lng": '145.060508',              "map":  map,              "icon": 'http://google-maps-icons.googlecode.com/files/sailboat-tourism.png',              "description": 'Vikash Rathee.  This is test Description 
Pin Code by City' } ];

Answer by MANISH LANGA for How to change icon on Google map marker


try this

var locations = [          ['San Francisco: Power Outage', 37.7749295, -122.4194155,'http://labs.google.com/ridefinder/images/mm_20_purple.png'],          ['Sausalito', 37.8590937, -122.4852507,'http://labs.google.com/ridefinder/images/mm_20_red.png'],          ['Sacramento', 38.5815719, -121.4943996,'http://labs.google.com/ridefinder/images/mm_20_green.png'],          ['Soledad', 36.424687, -121.3263187,'http://labs.google.com/ridefinder/images/mm_20_blue.png'],          ['Shingletown', 40.4923784, -121.8891586,'http://labs.google.com/ridefinder/images/mm_20_yellow.png']      ];        //inside the loop  marker = new google.maps.Marker({                  position: new google.maps.LatLng(locations[i][1], locations[i][2]),                  map: map,                  icon: locations[i][3]              });  

Answer by Vicky for How to change icon on Google map marker


Manish, Eden after your suggestion: here is the code. But still showing the red(Default) icon.

            

Answer by Pavi for How to change icon on Google map marker


we can change the icon of markers, i did it on right click event. Lets see if it works for you...

// Create a Marker  var marker = new google.maps.Marker({      position: location,      map: map,      title:'Sample Tool Tip'    });      // Set Icon on any event  google.maps.event.addListener(marker, "rightclick", function() {          marker.setIcon('blank.png'); // set image path here...  });  

Answer by gho.morteza for How to change icon on Google map marker


var marker = new google.maps.Marker({    position: myLatLng,    map: map,    icon: 'your-icon.png'  });  


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.