[OpenLayers-Users] GeoJSON based vector-layer with openstreetmaps

Thomas Gratier osgeo.mailinglist at gmail.com
Tue Jul 31 14:36:01 PDT 2012


Hello,

It's because when you're using tiles from OSM, the projection is 900913
(Google Spherical Mercator) and on WMS it is 4326.
You json is in the same projection althought your map are not in the same
projection and overlays fail because of this.

Do in you javascript debugger map.getProjection() on the example
http://poab.org/openlayers/geojson_osm.html
You get EPSG:900913
On your other example e.g http://poab.org/openlayers/geojson_wms.html, the
same command give you EPSG:4326
Refer to this page
http://docs.openlayers.org/library/spherical_mercator.html for further
explanations you seem to miss

Regards

ThomasG






2012/7/31 Christian Benke <benkokakao at gmail.com>

> Hello!
>
> I'm having difficulties to understand some basics of openlayers and
> projection. I'm trying to put tracks in geojson-format on a map. This
> works just fine with a WMS-Layer, but i seem to miss a crucial
> connection when trying to display it on an OSM-layer.
>
> I've tried to decipher the example at
> http://openlayers.org/dev/examples/fusiontables.html(Which uses
> GeoJSON on OSM) to adapt it to my needs, but as it is a lot more
> abstract than the very basic example-script i'm starting off, i get
> stuck even earlier when trying to change the geodata-source to my
> flatfile.
>
> Here is my basic example with WMS:
> http://poab.org/openlayers/geojson_wms.html
>
> And here's the same, but the map-layer is of OSM:
> http://poab.org/openlayers/geojson_osm.html
>
> On both maps i try to display GeoJSON-data from
> http://poab.org/openlayers/gpx2json.js, with WMS this works fine, with
> OSM it doesn't.
>
> I guess the problem lies within the projection/transformation of the
> GeoJSON-data, but i'm having a hard time figuring out how this is
> supposed to work and why the tracks are not displayed at all(Or at
> least how i can get it to tell me errors while parsing, if there are
> any).
> Obviously the WMS-layer is displayed very differently than the
> OSM-layer, so i assume that the GeoJSON-data also has to be adapted to
> be OSM-projection so it can be displayed on top of it?
>
> A related question: Why does the OSM-Layer need to be transformed to a
> different projection for centering it, not just setCenter with lon,
> lat and zoom like WMS?
>
> These are probably very basic questions for an experienced user - i'm
> currently a bit overwhelmed by the amount of information to digest
> while trying to get a understanding of GIS - i ask for patience, i'll
> probably post a few more ignorant questions to this list in the next
> few weeks.
>
> Best regards,
> Christian
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120731/a292c493/attachment.html>


More information about the Users mailing list