[OpenLayers-Users] GeoJSON based vector-layer with openstreetmaps
Christian Benke
benkokakao at gmail.com
Wed Aug 8 02:00:38 PDT 2012
Hello!
Sorry for the late reply!
Thanks for the link to the "spherical mercator" documentation, that helped
me to understand the underlying problem.
With
var geojson_format = new OpenLayers.Format.GeoJSON({
'internalProjection': new OpenLayers.Projection("EPSG:900913"),
'externalProjection': new OpenLayers.Projection("EPSG:4326")
});
it was actually very easy to transform the json-data to the required
projection.
Best regards,
Christian
On 31 July 2012 23:36, Thomas Gratier <osgeo.mailinglist at gmail.com> wrote:
> 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
>>
>
>
> _______________________________________________
> 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/20120808/25460bb3/attachment.html>
More information about the Users
mailing list