2 //= require leaflet.osm
4 window.onload = function () {
5 var query = (window.location.search || '?').substr(1),
8 var pairs = query.split('&');
9 for (var i = 0; i < pairs.length; i++) {
10 var parts = pairs[i].split('=');
11 args[parts[0]] = decodeURIComponent(parts[1] || '');
14 var map = L.map("map");
15 map.attributionControl.setPrefix('');
16 map.removeControl(map.attributionControl);
18 if (!args.layer || args.layer === "mapnik" || args.layer === "osmarender") {
19 new L.OSM.Mapnik().addTo(map);
20 } else if (args.layer === "cyclemap" || args.layer === "cycle map") {
21 new L.OSM.CycleMap().addTo(map);
22 } else if (args.layer === "transportmap") {
23 new L.OSM.TransportMap().addTo(map);
24 } else if (args.layer === "mapquest") {
25 new L.OSM.MapQuestOpen().addTo(map);
26 } else if (args.layer === "hot") {
27 new L.OSM.HOT().addTo(map);
31 L.marker(args.marker.split(','), {icon: L.icon({
32 iconUrl: <%= asset_path('images/marker-icon.png').to_json %>,
33 iconSize: new L.Point(25, 41),
34 iconAnchor: new L.Point(12, 41),
35 shadowUrl: <%= asset_path('images/marker-shadow.png').to_json %>,
36 shadowSize: new L.Point(41, 41)
41 var bbox = args.bbox.split(',');
42 map.fitBounds([L.latLng(bbox[1], bbox[0]),
43 L.latLng(bbox[3], bbox[2])]);
48 map.addControl(new L.Control.OSMReportAProblem());
51 L.Control.OSMReportAProblem = L.Control.Attribution.extend({
53 position: 'bottomright',
54 prefix: '<a href="http://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}">Report a problem</a>'
57 onAdd: function (map) {
58 var container = L.Control.Attribution.prototype.onAdd.call(this, map);
60 map.on('moveend', this._update, this);
65 _update: function () {
66 L.Control.Attribution.prototype._update.call(this);
68 this._container.innerHTML =
69 this._container.innerHTML
70 .replace('{x}', this._map.getCenter().lat)
71 .replace('{y}', this._map.getCenter().lng)
72 .replace('{z}', this._map.getZoom());