[OSM-dev] OSM and OpenLayers Projections

mike mike at bristolbeat.co.uk
Fri Aug 10 15:46:47 BST 2007


Hi Chris,

Thanks for your response.  Firstly the point of the excercise is to NOT use
google maps, so using their API to present the osm maps seems like the wrong
approach.  Actually we already have an example that uses the google api and
the google tiles, but I was hoping to achieve an open source alternative
approach.

I think it's worth persuing this because an easily reusable solution to
allow people to use osm maps with various overlays might be a good way to
increase use of osm.  I know mashups are unpopular by the purists, but
they're very popular with the public :)


On 10/08/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
>
> You've commented out all the parts of the OpenStreetMap map options that
> actually make the data geographically correct. That's probably a mistake
> :)


Yes, I was merging it towards the basic openlayers kml example to see where
it broke.

OpenStreetMap tile data is projected. In order to use it in OpenLayers,
> you need to reproject all the data you are using -- OpenLayers does not
> support clientside reprojection. This means you have two options:
>
> * Reproject your KML data. This means changing the coordinates from
>    Lat/Lon to projected x/y coodinates in the "Google Projection":
>    http://spatialreference.org/ref/user/6/


This seems the best option.  The OpenLayers/Format/KML.js file can be
modified to translate the co-ordinates as they are read, but I'm not sure
that I'm totally happy with this solution - it feels like a hack.  However
it does work!

In fact, using the same method I can load OSM data directly into a vector
layer as well - see http://www.bristolbeat.co.uk/phpmap/openstreetmap2.html

* Use different tiles. If you don't care about the projected/not
>    projected data, you could set up a different, non-projected
>    datasource. If you'd like to go that route, I can even set one up for
>    you -- I have an old one running under http://tilecache.org/demo.html
>    , but I can set it up along with the other osgeo-hosted OSM layers
>    (Google Projection, Simple Mercator projection) that we have set up.


I'm a little lost here - I have a bunch of layers in this latest demo and
the only ones that don't work are the old Mapnik / Osmarender tiles.

Still, it seems a shame that we have to fudge the lat/lon values to the osm
projection as this appears to break openlayers, or at least means that any
extra layers will have to be hacked to change the co-ords.  It would seem
better to make osm work with the standard co-ords, or am I missing
something?

mike


There is, of course, the option of simply using Google Maps for your
> data. I'm sure someone can provide the right incantation to make Google
> load OSM data, and Google will reproject KML to match their internal
> projection.
>
> If you'd like help with either of the first two, please reply and I can
> help you understand the technical stuff you might need to know to get
> set up.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070810/8dacdb83/attachment.html>


More information about the dev mailing list