Changing KML Placemark icons on click in Google Maps API V3 -


i trying change kml placemark icons of kml overlay in sample maps application working on.

here's sample code -

function seekml() {  var mylatlng = new google.maps.latlng(40.65, -73.95); var myoptions = {     zoom: 14,     maptypecontrol: true,     center: mylatlng,     maptypecontroloptions: {         style: google.maps.maptypecontrolstyle.dropdown_menu,      position: google.maps.controlposition.top_right     },     navigationcontrol: true,     navigationcontroloptions: {         style: google.maps.navigationcontrolstyle.small     },     maptypeid: google.maps.maptypeid.roadmap }; url_end = "?nocache=" + (new date()).valueof(); //for no kml caching  mykml = "http://kmlscribe.googlepages.com/samplesinmaps.kml" + url_end  gmap = new google.maps.map(document.getelementbyid("map"), myoptions); var ctalayer = new google.maps.kmllayer(mykml,{suppressinfowindows: true}); ctalayer.setmap(gmap);  google.maps.event.addlistener(ctalayer, 'click', function(event) {                   this.seticon(gyellowicon);   }); } 

gyellowicon has been defined in code before -

var gyellowicon = new google.maps.markerimage(   "image url",   new google.maps.size(31, 31),   new google.maps.point(0, 0),   new google.maps.point(6, 20)); 

i want change kml overlay placemarks, when user clicks on of placemarks shown on kml overlay. above code doesn't work.

i'm working on exact same thing and, in case, directly edit kml file. if have access , can edit it, here's did:

1) right under <document> tag, paste this:

<style id="desired_id">   <iconstyle>     <icon>       <href>http://www.yourwebsite.com/your_preferred_icon.png</href>       <scale>1.0</scale>     </icon>       </iconstyle> </style> 

the scale parameter not supported in google maps @ moment. here can check supported elements of kml in google maps:

http://code.google.com/intl/en-en/apis/kml/documentation/kmlelementsinmaps.html

and here you've got info compatibility between kml , gmaps:

http://code.google.com/intl/en-en/apis/kml/documentation/mapssupport.html

2) once you've defined you're style, can refer on each placemark item adding following it:

<styleurl>#desired_id</styleurl> 

now, placemarks should display showing custom icon.

hope helps.

edit: sorry didn't see on click part. isn't quite need then. i'll leave in case helps else. sorry that.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -