Quick question with regards to kml layers

39 views
Skip to first unread message

Nathan Raley

unread,
Jun 21, 2010, 11:08:59 AM6/21/10
to Google Maps JavaScript API v3
I have a quick question regarding kml layers.

I am reading a file with several coordinates and am currently generating anywhere between 100-2000+ markers on my map, each has a click event associated with them now, b/c of the changes between the v2 and v3 of the api, that returns the position of the marker.

Currently I am using marker manager to add these markers to the map in bulk and I am managing how many are being shown at different view stages.

Would I get better functionality using kml layers to render the makers and handle the kml event than I would be using marker manager to handle the markers?  I'm assuming there's no way to bulk add markers to a kml layer by using something like marker manager is there?

Chad Killingsworth

unread,
Jun 21, 2010, 11:26:02 AM6/21/10
to Google Maps JavaScript API v3
On Jun 21, 10:08 am, Nathan Raley <nlrale...@gmail.com> wrote:
> I have a quick question regarding kml layers.
>
> I am reading a file with several coordinates and am currently generating
> anywhere between 100-2000+ markers on my map, each has a click event
> associated with them now, b/c of the changes between the v2 and v3 of the
> api, that returns the position of the marker.
>
> Currently I am using marker manager to add these markers to the map in bulk
> and I am managing how many are being shown at different view stages.
>
> Would I get better functionality using kml layers to render the makers and
> handle the kml event than I would be using marker manager to handle the
> markers?

From a performance standpoint - definitely yes.

> I'm assuming there's no way to bulk add markers to a kml layer by
> using something like marker manager is there?

You don't add anything to a KmlLayer once it has been created. You can
add new layers which will add more data to the same rendered tile
layer.

Chad Killingsworth

Nathan Raley

unread,
Jun 21, 2010, 12:27:40 PM6/21/10
to google-map...@googlegroups.com
So how hard would it be to convert my markers into a kml file to add as a kml overlay?


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Nathan Raley

unread,
Jun 21, 2010, 12:32:27 PM6/21/10
to google-map...@googlegroups.com
Finally found some documentation on kml files, I had to do some digging.

Basically for a simple marker I'd just need to define the kml entry as something along the lines of:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark> </kml>

Is this correct?  If so is there a way to go about doing this dynamically on the fly?  The reason I ask is that I am reading a file from my c++ app and my map is basically on an embedded html object.  I read the information from the c and was just passing it to the javascript to store and then create the markers then bulk add with marker manager.  Is there a way to create this on the fly, or will I need to work this into my c++ program and save another file in this format instead?

Chad Killingsworth

unread,
Jun 21, 2010, 2:37:56 PM6/21/10
to Google Maps JavaScript API v3
On Jun 21, 11:32 am, Nathan Raley <nlrale...@gmail.com> wrote:
> Finally found some documentation on kml files, I had to do some digging.
>
> Basically for a simple marker I'd just need to define the kml entry as
> something along the lines of:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://www.opengis.net/kml/2.2">
>   <Placemark>
>     <name>Simple placemark</name>
>     <description>Attached to the ground. Intelligently places itself
>        at the height of the underlying terrain.</description>
>     <Point>
>       <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
>     </Point>
>   </Placemark>
> </kml>
>
> Is this correct?

Looks like it to me - although I'm no expert at mentally parsing
KML :-)

>If so is there a way to go about doing this dynamically on
> the fly?  The reason I ask is that I am reading a file from my c++ app and
> my map is basically on an embedded html object.  I read the information from
> the c and was just passing it to the javascript to store and then create the
> markers then bulk add with marker manager.  Is there a way to create this on
> the fly, or will I need to work this into my c++ program and save another
> file in this format instead?

I dynamically generate my Kml. Remember though, that Kml files MUST be
served from a public web server. Google's servers actually request the
file and parse it. The client only sees the resulting tiles - not the
Kml file directly.

You can use whatever server-side language/platform you are most
comfortable with.

Chad Killingsworth
> >> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> >> .

Nathan Raley

unread,
Jun 21, 2010, 3:31:44 PM6/21/10
to google-map...@googlegroups.com
Hmm, might not be worth it for me to implement it then otherwise I might end up with a bunch of different files being hosted on the web server, not too entirely bad but currently not worth the recoding investment that would take atm.  

I was just considering this b/c of the lack of the map click event to return an overlay or overlaylatlng which required me to create individual listeners for every marker.  This would give me the option to create a generic listener again.

To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages