[OpenLayers-Users] Building OpenLayers: wrong coordinates

Sebastian Klemm sebastian_klemm at freenet.de
Mon May 21 16:36:25 PDT 2012


Am 16.05.2012 14:43, schrieb Sebastian Klemm:
> I tried to build my own shrunk OL library to use in an OpenStreetMap web
> application but have some problems.
>
> Building went fine so far and the map is shown but when I try to set its
> center like this
>
> var center = new OpenLayers.LonLat(10, 50).transform(new
> OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
>
> if (!map.getCenter()) {
>      map.setCenter(center, 15);
> }
>
> the center of the map is somewhere in Atlantic Ocean near 0°N/0°E
> instead of Germany. It seems to me like a problem concerning projection
> as the given lon/lat coordinates are taken as pixel coordinates.
>
> If I use the bundled OL library (should be the same as building with
> 'full.cfg') it works well, so I guess I missed something in the build
> config.
>
> This is the config beeing used to build:
>
> [first]
> OpenLayers/SingleFile.js
> OpenLayers.js
> OpenLayers/BaseTypes.js
> OpenLayers/BaseTypes/Class.js
> OpenLayers/Util.js
> Rico/Corner.js
>
> [last]
>
> [include]
> OpenLayers/Ajax.js
> OpenLayers/Console.js
> OpenLayers/Control.js
> OpenLayers/Events.js
> OpenLayers/Format.js
> OpenLayers/Icon.js
> OpenLayers/Layer.js
> OpenLayers/Map.js
> OpenLayers/Popup.js
> OpenLayers/Projection.js
> OpenLayers/Protocol.js
> OpenLayers/Request.js
> OpenLayers/Tile.js
> OpenLayers/Control/ArgParser.js
> OpenLayers/Control/Attribution.js
> OpenLayers/Control/LayerSwitcher.js
> OpenLayers/Control/Navigation.js
> OpenLayers/Control/PanZoomBar.js
> OpenLayers/Control/Permalink.js
> OpenLayers/Control/ScaleLine.js
> OpenLayers/Format/GPX.js
> OpenLayers/Format/JSON.js
> OpenLayers/Layer/HttpRequest.js
> OpenLayers/Layer/Image.js
> OpenLayers/Layer/Markers.js
> OpenLayers/Layer/Text.js
> OpenLayers/Layer/WMS.js
> OpenLayers/Layer/XYZ.js
> OpenLayers/Popup/FramedCloud.js
> OpenLayers/Tile/Image.js
>
> [exclude]

The solution is to add this line to [include]:

OpenLayers/Layer/SphericalMercator.js



More information about the Users mailing list