[OpenLayers-Users] Pattern for overlaying KML data on Google Map layer?

Martin Davis mbdavis at refractions.net
Mon Nov 3 18:55:08 EST 2008


Thanks for the very helpful answer, Chris.  Obviously I wasn't RT'ing 
the right parts of the FM!

Perhaps it might be helpful to have a link to the example from the FAQ 
entry.

Anyway, compliments and kudos on a very well documented project!

Martin

Christopher Schmidt wrote:
> On Mon, Nov 03, 2008 at 01:52:22PM -0800, Martin Davis wrote:
>   
>> Is there a standard pattern for creating a map with both a Google Maps 
>> layer and a regular KML file, so that they overlay correctly?  My first 
>> attempt simply added both layers in with no particular reprojection, and 
>> while this makes both visible and *sort of* in the same reference 
>> system, the KML file "drifts" when I pan the map vertically.
>>
>> I realize that there are a fair number of messages about this kind of 
>> thing, but I'm finding it a bit of work to figure out *exactly* how this 
>> should be done.  Or is it even possible?  Do you have to reproject the 
>> KML file to match the GM projection?
>>     
>
> There are two parts to your question. One is "How do I use Vectors with
> Google Maps?"
>
> This may be answered by
> http://faq.openlayers.org/vector-related-questions/why-dont-my-vector-features-work-over-google-yahoo-virtual-earth-etc/
> -- certainly, that is the question it is intended to answer. 
>
> The second question is "How can I use KML on top of a Spherical Mercator
> map?" The wikipage linked in the FAQ entry points to
> http://crschmidt.net/~crschmidt/spherical_mercator.html#reprojecting-vector-data
> , which shows how to reproject vector data on top of a spherical
> mercator map.
>
> Putting those together seems to me to solve your problem. 
>
> Lastly, going to http://openlayers.org/dev/examples/ and searching for
> "Google Maps KML" brings up
> http://openlayers.org/dev/examples/sundials-spherical-mercator.html ,
> which has both an OpenStreetMap layer and a Google Maps layer with KML
> underneath them.
>
> Regards,
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the Users mailing list