[openstreetmap-website] Move param-based map configuration to client (#94)

Tom Hughes notifications at github.com
Thu Sep 13 14:16:03 BST 2012


> +    mapParams.lon = parseFloat(params.lon);
> +    mapParams.lat = parseFloat(params.lat);
> +    mapParams.zoom = parseInt(params.zoom || 5);
> +    mapParams.object_zoom = false;
> +  } else if (params.mlon && params.mlat) {
> +    mapParams.lon = parseFloat(params.mlon);
> +    mapParams.lat = parseFloat(params.mlat);
> +    mapParams.zoom = parseInt(params.zoom || 12);
> +    mapParams.object_zoom = false;
> +  } else if (loc = document.cookie.replace(/(?:^|.*;\s*)_osm_location\s*=\s*((?:[^;](?!;))*[^;]?).*/, "$1")) {
> +    loc = loc.split("|");
> +    mapParams.lon = parseFloat(loc[0]);
> +    mapParams.lat = parseFloat(loc[1]);
> +    mapParams.zoom = parseInt(loc[2]);
> +    mapParams.layers = loc[3];
> +  } else if (OSM.home) {

Yes, it is a bit crazy, but I'm not sure there is that much that we can unify because the point is that they are (mostly) different rather than redundant.

There may be something we can do about the four or so different ways of passing a location in the url (but back compatibility is a big issue here) but with one exception (bbox vs minlon/minlat/maxlon/maxlat) they all exist for a reason.

Assuming there is nothing in the URL then we look to cookies, then to the user's home location, then to geoip and finally to a fixed default.

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/94/files#r1597360
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20120913/d2b8386f/attachment.html>


More information about the rails-dev mailing list