[OpenLayers-Users] Pattern for overlaying KML data on Google
Map layer?
Christopher Schmidt
crschmidt at metacarta.com
Mon Nov 3 18:43:41 EST 2008
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,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list