0

I am using Google Maps JavaScript API v3. I want to wire up to the Google Maps, KmlLayer's KmlMouseEvent for all of the default places that show up when I create the map.

The only way I have found that gives me a reference to the KmlLayer is to create it. However, I want all the default data.

This post explains how to wire up to the KmlMouseEvent click if I am loading the KML from an external file. However, I can't find any documentation in the API that allows me to access the click event of the default KmlLayer.

The best solution I've been able to come up with is to make a call to the Places API and generate a KML file from the returned data. There's just got to be a better way.

Community
  • 1
  • 1
smartcaveman
  • 41,281
  • 29
  • 127
  • 212

2 Answers2

3

1: First of all google maps v3 is not based on kml layer, so there is nothing default to get in kml

2: Even if it was kml based, getting default kml layer would not be possible given the current state of google maps, you may have to change the gooogle maps api, which is otherwise unrealistic. In other words you wont be using google maps actually.

Online Mapping with Google Maps API for your reference

defau1t
  • 10,593
  • 2
  • 35
  • 47
0

I'm not shure if i correctly understand your question... You would have access to every click event on default google-maps items like trainstations, restaurants, places, etc...?

If this is correct, let me tell you the following:

Default google-maps layer is not a KML-Layer. The first layer is dynamic, and does not load/render the defined places on the whole map, like KML-Layers do. The layer loads its items on viewport-change. This makes sense if you think about performance and traffic. So if you want to set click events for default places, you have to do this on every viewport change.

Back to your Question... I'm not shure, but i think this is a security restriction by Google. Because if you can access the default click event, you where able to change contents you are not privileged to change (like places Infobox). The only way to change the default click event is changing the google js-code, and this will break the google usage policy ;)

I would like to help you, but I'm afraid your plan seems to be impossible.

PS: Sorry for the bad english, i'm swiss-german ;)

Cheers. Frank

frank_neff
  • 952
  • 8
  • 16
  • Where can I find documentation supporting your assertion that the default google-maps layer is **not** a KML - Layer? – smartcaveman Nov 16 '11 at 18:54
  • 1
    KML is just one of many different Layers you can use in Google Maps. KML is an open Format to render geodata as overlay. Many different maps support it... Here you can read, that google maps has a Class to render KML files, but google maps is NOT based on KML: http://googlegeodevelopers.blogspot.com/2010/05/kml-traffic-and-bicycling-layers-come.html Read here about what KML is, and what it's NOT: http://en.wikipedia.org/wiki/Keyhole_Markup_Language And layers: http://bit.ly/tb3Fcb If you understand the principle of KML and Layers, you know baselayer can't be KML ;) – frank_neff Nov 17 '11 at 10:55
  • 2
    @frank_neff is right... Google Maps API v3 Adds support for KML, Traffic, and Bike Routes. Asking for the default KML layer is like asking for the default 'bike routes' layer. Which obviously make no sense. – Omtara Nov 17 '11 at 13:16