2 <% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) %>
3 PIWIK_LOCATION: <%= PIWIK_LOCATION.to_json %>,
4 PIWIK_SITE: <%= PIWIK_SITE.to_json %>,
7 MAX_REQUEST_AREA: <%= MAX_REQUEST_AREA.to_json %>,
8 SERVER_URL: <%= SERVER_URL.to_json %>,
9 API_VERSION: <%= API_VERSION.to_json %>,
10 STATUS: <%= STATUS.to_json %>,
11 MAX_NOTE_REQUEST_AREA: <%= MAX_NOTE_REQUEST_AREA.to_json %>,
13 apiUrl: function (object) {
14 var url = "/api/" + OSM.API_VERSION + "/" + object.type + "/" + object.id;
16 if (object.type != "node") {
18 } else if (object.version) {
19 url += "/" + object.version;
25 mapParams: function (search) {
26 var params = {}, mapParams = {}, bounds, loc;
28 search = (search || window.location.search).replace('?', '').split(/&|;/);
30 for (var i = 0; i < search.length; ++i) {
32 j = pair.indexOf('='),
33 key = pair.slice(0, j),
34 val = pair.slice(++j);
35 params[key] = decodeURIComponent(val);
38 if (params.mlon && params.mlat) {
39 mapParams.marker = true;
40 mapParams.mlon = parseFloat(params.mlon);
41 mapParams.mlat = parseFloat(params.mlat);
45 mapParams.layers = params.layers;
48 if (params.node || params.way || params.relation) {
49 mapParams.object_zoom = true;
52 mapParams.object = {type: 'node', id: parseInt(params.node)};
53 } else if (params.way) {
54 mapParams.object = {type: 'way', id: parseInt(params.way)};
55 } else if (params.relation) {
56 mapParams.object = {type: 'relation', id: parseInt(params.relation)};
61 params.bbox = params.bbox.split(',');
62 bounds = L.latLngBounds(
63 [parseFloat(params.bbox[1]),
64 parseFloat(params.bbox[0])],
65 [parseFloat(params.bbox[3]),
66 parseFloat(params.bbox[2])]);
67 } else if (params.minlon && params.minlat && params.maxlon && params.maxlat) {
68 bounds = L.latLngBounds(
69 [parseFloat(params.minlat),
70 parseFloat(params.minlon)],
71 [parseFloat(params.maxlat),
72 parseFloat(params.maxlon)]);
75 if (params.box === 'yes') {
76 mapParams.box = bounds;
79 // Decide on a map starting position. Various ways of doing this.
80 var hash = L.Hash.parseHash(location.hash);
82 mapParams.lon = hash.center.lng;
83 mapParams.lat = hash.center.lat;
84 mapParams.zoom = hash.zoom;
85 mapParams.object_zoom = false;
87 mapParams.bounds = bounds;
88 mapParams.object_zoom = false;
89 } else if (params.lon && params.lat) {
90 mapParams.lon = parseFloat(params.lon);
91 mapParams.lat = parseFloat(params.lat);
92 mapParams.zoom = parseInt(params.zoom || 5);
93 mapParams.object_zoom = false;
94 } else if (params.mlon && params.mlat) {
95 mapParams.lon = parseFloat(params.mlon);
96 mapParams.lat = parseFloat(params.mlat);
97 mapParams.zoom = parseInt(params.zoom || 12);
98 mapParams.object_zoom = false;
99 } else if (loc = $.cookie('_osm_location')) {
100 loc = loc.split("|");
101 mapParams.lon = parseFloat(loc[0]);
102 mapParams.lat = parseFloat(loc[1]);
103 mapParams.zoom = parseInt(loc[2]);
104 mapParams.layers = loc[3];
105 } else if (OSM.home) {
106 mapParams.lon = OSM.home.lon;
107 mapParams.lat = OSM.home.lat;
109 } else if (OSM.location) {
110 mapParams.bounds = L.latLngBounds(
111 [OSM.location.minlat,
112 OSM.location.minlon],
113 [OSM.location.maxlat,
114 OSM.location.maxlon]);
116 mapParams.lon = -0.1;
117 mapParams.lat = 51.5;
118 mapParams.zoom = parseInt(params.zoom || 5);
121 mapParams.notes = params.notes == "yes";
124 mapParams.note = parseInt(params.note);
127 var scale = parseFloat(params.scale);
129 mapParams.zoom = Math.log(360.0 / (scale * 512.0)) / Math.log(2.0);
135 formatHash: function(args) {
136 var precision = zoomPrecision(args.zoom);
137 return '#' + args.zoom +
138 '/' + args.lat.toFixed(precision) +
139 '/' + args.lon.toFixed(precision);