OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2009-01-23 02:32:11

Zambelli Limitada
Member
Registered: 2009-01-23
Posts: 3

OpenLayers Permalinks to work at OSM Chile

Some time ago I installed OpenLayers in the OpenStreetMap Chile website (http://www.openstreetmap.cl/). The problem is that I have not been able to make the Edit Permalink work. As Jochen Topf indicated to me, the problem is probably related with the Projection configured in OL.

The main problem with this is that my JavaScript knowledge is pretty near to zero. So even though I have tried a couple of changes in the projection and units variables in the http://www.openstreetmap.cl/index.html and http://www.openstreetmap.cl/OpenLayers.js files, I have not achieved anything.

Do you see anything wrong with those files?

Offline

#2 2009-01-23 09:49:40

Lambertus
Administrator
From: Apeldoorn (NL)
Registered: 2007-03-17
Posts: 3,269
Website

Re: OpenLayers Permalinks to work at OSM Chile

The keywords are 'displayprojection'  and 'projection'. See the OpenLayers examples in the wiki, like the Simple example
:

Include the openstreetmap OL file:

<script src="http://openstreetmap.org/openlayers/OpenStreetMap.js">

Then create the map using the correct projections:

// Map definition based on http://wiki.openstreetmap.org/index.php … le_Example
map = new OpenLayers.Map ("map", {
            controls:[
                new OpenLayers.Control.Navigation(),
                new OpenLayers.Control.PanZoomBar(),
                new OpenLayers.Control.LayerSwitcher(),
                new OpenLayers.Control.Attribution()
        ],
            eventListeners: {
                "changebaselayer": onChangeBaseLayer
                    },
            maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
            maxResolution: 156543.0399,
            numZoomLevels: 20,
            units: 'm',
            projection: new OpenLayers.Projection("EPSG:900913"),
            displayProjection: new OpenLayers.Projection("EPSG:4326")

} );

Then you can define your layers, like the standard OpenStreetMap mapnik layer:

layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");


Mapping tools: Garmin GPSmap 60CSx, Giant Terrago 2002

Offline

#3 2009-01-23 12:46:29

emj
Member
From: .se (59.3N17.99E) 0735969076
Registered: 2006-06-18
Posts: 949

Re: OpenLayers Permalinks to work at OSM Chile

oh! Thanks Lambertus this explanation was really needed

the "Openlayers mercator coordinates instead of GPS coordinates" problem is common when using Open layers. It really sucks not having WGS84 coordinates (GPS coordinates) in Openlayers.


PS the meaning of this post was to provide interesting keywords  DS..

Last edited by emj (2009-01-23 19:44:22)

Offline

#4 2009-01-23 14:15:58

Lambertus
Administrator
From: Apeldoorn (NL)
Registered: 2007-03-17
Posts: 3,269
Website

Re: OpenLayers Permalinks to work at OSM Chile

EPSG:900913 is Google projection is spherical Mercator projection and WGS84 is EPSG:4326 smile

http://trac.openlayers.org/wiki/SphericalMercator
http://spatialreference.org/ref/epsg/4326/

So, afaik, what happens is that you have data in the Google projection and wish to view it in a WGS84 projection. That is what the 'projection' and 'displayprojection' settings are for...

OpenLayers documentation wrote:

A mixin for layers that wraps up the pieces neccesary to have a coordinate conversion for working with commercial APIs which use a spherical mercator projection.  Using this layer as a base layer, additional layers can be used as overlays if they are in the same projection.


Mapping tools: Garmin GPSmap 60CSx, Giant Terrago 2002

Offline

#5 2009-01-23 23:13:06

Zambelli Limitada
Member
Registered: 2009-01-23
Posts: 3

Re: OpenLayers Permalinks to work at OSM Chile

I can not use the OpenLayers.js file directly from the OpenStreetMap or OpenLayers website, since I changed the image and position of the buttons. to fit the website design. If you know how to use the external file and change those variables at the same time, please let me know.

Thanks

Offline

#6 2009-01-25 01:54:11

emj
Member
From: .se (59.3N17.99E) 0735969076
Registered: 2006-06-18
Posts: 949

Re: OpenLayers Permalinks to work at OSM Chile

It's faster for your users if you use a local copy.

Offline

#7 2009-01-25 22:18:21

Zambelli Limitada
Member
Registered: 2009-01-23
Posts: 3

Re: OpenLayers Permalinks to work at OSM Chile

I do not have any problem in using the local or remote files, as long as everything works the way I want. I know there are some Pros and Cons for each method, but again, the most important thing for my is that every link in the site works the right way (bringing the Map, the Blog, the Comparison System, the Wiki, and the Edit interface to the people).

I have to admit that I have the bad habit (since I am not a programmer or engineer) of taking pieces of code from other sites, editing and testing it until it works. But that probably has added a lot of unnecessary code to this website. 

If someone is willing to take a look at the code behind the scene and tell me if he/she sees something wrong or unused, I will be waiting for your comments. Also if you see a way of making work both the Permalink (It works now) and the Edit permalink, that will help me a lot.

Thanks

Offline

Board footer

Powered by FluxBB