[OSM-dev] Addressable maps & updated URL?

Christophe Cattelain xof at skynet.be
Thu Oct 4 13:58:27 BST 2007


I did not find where I would modify the OSM sources (and wouldn' t dare
to... ;-).

    Here is an other example (*):

      
http://users.skynet.be/chricat/OSM/xofOSM.html#lat=-4.32&lon=15.3&z=13
          (Kinshasa, Wow! :-)


I think there are 3 places to modify :

-----------
1/ In the code where lat, lon, zoom,...  is extracted from the URL. 
Something like :

>   query = location.search;

has to be replaced by (something like)

>    if ((pos = location.href.indexOf('#')) != -1)
>                {
>                url = location.href.substring(0, pos);
>                var query = location.href.substring(pos+1);
>                }
>        else    {
>                var query = location.search.substring(1);
>                url = location.pathname;
>                }
-----------
2/ in the 'moveend' handler,
replace

>    document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + ","
+ zoom + "," + layers;

by (something like)

>    location.href =
url+"#lat="+lonlat.lat.toFixed(6)+"&lon="+lonlat.lon.toFixed(6)+"&zoom="+zoom+"&layers="+layers;

(0.000001 degree seems enough, no? (< 0.12 meter (?), 1 pixel @ zoom-12;
but, true, 33 pixels @ zoom-17))
-----------
3/ Get rid of the cookie mecanism.


Of course, it has to be further discussed, tested and properly released,
but (I think) it is very simple.



xof
---------------------------------
The advantages of the 'updated URL' are :
    - there are no surprises when I refresh the page, I don't go to a
(forgotten) place when I just want to go 'home',
    - I can have multiple views in different tabs.
    - I never forget to ask for a 'permalink' when I mail a view.

What would be nice too, would be to 're-center' the view when we come
back from the (potlatch) editor.

But, don't hurry, take your time.  I am very impressed by the scale of
this 'project'.  Don't crash the whole thing for a 'gadget'.  ;-)


(*) I had an home made (geologic) slippyMap demo :
       http://xofmaps.ibelgique.com/Chimay/nxofMaps.html
Unfortunately there are sometimes dirty deceptive advertizing on this
free web hosting...
      




More information about the dev mailing list