return false;
}
- var map = createMap("small_map", {
- layerControl: false,
- panZoomControl: false,
- attributionControl: false
+ var map = L.map("small_map", {
+ attributionControl: false,
+ zoomControl: false
+ }).addLayer(new L.OSM.Mapnik());
+
+ L.control.zoom({position: 'topright'})
+ .addTo(map);
+
+ $("#small_map").on("resized", function () {
+ map.invalidateSize();
});
var params = $("#small_map").data();
object.version = params.version - 1;
}
- addObjectToMap(object, {
+ addObjectToMap(object, map, {
zoom: true,
callback: function(extent) {
$("#loading").hide();
$(document).ready(function () {
var changesets = [], rects = {};
- var map = createMap("changeset_list_map");
+
+ var map = L.map("changeset_list_map", {
+ attributionControl: false,
+ zoomControl: false
+ }).addLayer(new L.OSM.Mapnik());
+
+ L.control.zoom({position: 'topright'})
+ .addTo(map);
+
+ $("#changeset_list_map").on("resized", function () {
+ map.invalidateSize();
+ });
+
var group = L.featureGroup().addTo(map);
$("[data-changeset]").each(function () {
$(document).ready(function () {
- var marker;
+ var marker, map;
function setLocation(e) {
$("#latitude").val(e.latlng.lat);
var params = $("#map").data();
var centre = [params.lat, params.lon];
- var map = createMap("map");
+
+ map = L.map("map", {
+ attributionControl: false,
+ zoomControl: false
+ }).addLayer(new L.OSM.Mapnik());
+
+ L.control.zoom({position: 'topright'})
+ .addTo(map);
+
+ $("#map").on("resized", function () {
+ map.invalidateSize();
+ });
map.setView(centre, params.zoom);
//= require index/notes
//= require index/map_ui
+var map, layers; // TODO: remove globals
+
$(document).ready(function () {
- var permalinks = $("#permalink").detach().html();
var marker;
var params = OSM.mapParams();
- var map = createMap("map", {
+
+ map = L.map("map", {
+ attributionControl: false,
zoomControl: false,
layerControl: false
- }, {
- locateControl: true
+ });
+
+ layers = mapLayers();
+
+ for (var i = 0; i < layers.length; i++) {
+ layers[i].layer = new (layers[i].klass)(layers[i]);
+ }
+
+ layers[0].layer.addTo(map);
+
+ $("#map").on("resized", function () {
+ map.invalidateSize();
});
L.control.zoom({position: 'topright'})
L.control.scale().addTo(map);
- map.attributionControl.setPrefix(permalinks);
-
map.on("moveend layeradd layerremove", updateLocation);
if (!params.object_zoom) {
}
if (params.object) {
- addObjectToMap(params.object, { zoom: params.object_zoom });
+ addObjectToMap(params.object, map, { zoom: params.object_zoom });
}
handleResize();
}
if (data.type && data.id) {
- addObjectToMap(data, { zoom: true, style: { opacity: 0.2, fill: false } });
+ addObjectToMap(data, map, { zoom: true, style: { opacity: 0.2, fill: false } });
}
if (marker) {
$("#query").focus();
}
});
+
+function getMapBaseLayer() {
+ for (var i = 0; i < layers.length; i++) {
+ if (map.hasLayer(layers[i].layer)) {
+ return layers[i];
+ }
+ }
+}
+
+function getMapLayers() {
+ var layerConfig = "";
+ for (var i = 0; i < layers.length; i++) {
+ if (map.hasLayer(layers[i].layer)) {
+ layerConfig += layers[i].layerCode;
+ }
+ }
+ return layerConfig;
+}
+
+function setMapLayers(layerConfig) {
+ var foundLayer = false;
+ for (var i = 0; i < layers.length; i++) {
+ if (layerConfig.indexOf(layers[i].layerCode) >= 0) {
+ map.addLayer(layers[i].layer);
+ foundLayer = true;
+ } else {
+ map.removeLayer(layers[i].layer);
+ }
+ }
+ if (!foundLayer) {
+ map.addLayer(layers[0].layer);
+ }
+}
L.Icon.Default.imagePath = <%= "#{asset_prefix}/images".to_json %>;
-var map;
-var layers;
var objectLayer;
var objectLoader;
-function createMap(divName, options, moreOptions) {
- if (!layers) {
- layers = [
- {
- klass: L.OSM.Mapnik,
- attribution: "",
- keyid: "mapnik",
- layerCode: "M",
- name: I18n.t("javascripts.map.base.standard")
- },
- {
- klass: L.OSM.CycleMap,
- attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
- keyid: "cyclemap",
- layerCode: "C",
- name: I18n.t("javascripts.map.base.cycle_map")
- },
- {
- klass: L.OSM.TransportMap,
- attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
- keyid: "transportmap",
- layerCode: "T",
- name: I18n.t("javascripts.map.base.transport_map")
- },
- {
- klass: L.OSM.MapQuestOpen,
- attribution: "Tiles courtesy of <a href='http://www.mapquest.com/' target='_blank'>MapQuest</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png'>",
- keyid: "mapquest",
- layerCode: "Q",
- name: I18n.t("javascripts.map.base.mapquest")
- }
- ];
- }
-
- moreOptions = moreOptions || {};
-
- options = $.extend({zoomControl: true, panZoomControl: true, layerControl: true}, options);
-
- map = L.map(divName, $.extend({}, options, {panControl: false, zoomsliderControl: false, maxZoom: 18}));
-
- if (map.attributionControl) {
- map.attributionControl.setPrefix('');
- }
-
-
- var layersControl = L.control.layers();
-
- if (options.layerControl) {
- layersControl.addTo(map);
- map.layersControl = layersControl;
- }
-
- if (moreOptions.locateControl) {
- var loc = L.control.locate({
- position: 'topright'
- });
- loc.addTo(map);
- }
-
- for (var i = 0; i < layers.length; i++) {
- layers[i].layer = new (layers[i].klass)(layers[i]);
- layersControl.addBaseLayer(layers[i].layer, layers[i].name);
- }
-
- layers[0].layer.addTo(map);
-
- $("#" + divName).on("resized", function () {
- map.invalidateSize();
- });
-
- return map;
+function mapLayers() {
+ return [
+ {
+ klass: L.OSM.Mapnik,
+ attribution: "",
+ keyid: "mapnik",
+ layerCode: "M",
+ name: I18n.t("javascripts.map.base.standard")
+ },
+ {
+ klass: L.OSM.CycleMap,
+ attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
+ keyid: "cyclemap",
+ layerCode: "C",
+ name: I18n.t("javascripts.map.base.cycle_map")
+ },
+ {
+ klass: L.OSM.TransportMap,
+ attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
+ keyid: "transportmap",
+ layerCode: "T",
+ name: I18n.t("javascripts.map.base.transport_map")
+ },
+ {
+ klass: L.OSM.MapQuestOpen,
+ attribution: "Tiles courtesy of <a href='http://www.mapquest.com/' target='_blank'>MapQuest</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png'>",
+ keyid: "mapquest",
+ layerCode: "Q",
+ name: I18n.t("javascripts.map.base.mapquest")
+ }
+ ]
}
function getUserIcon(url) {
});
}
-function addObjectToMap(object, options) {
+function addObjectToMap(object, map, options) {
if (objectLoader) {
objectLoader.abort();
}
}
});
}
-
-function getMapBaseLayer() {
- for (var i = 0; i < layers.length; i++) {
- if (map.hasLayer(layers[i].layer)) {
- return layers[i];
- }
- }
-}
-
-function getMapLayers() {
- var layerConfig = "";
- for (var i = 0; i < layers.length; i++) {
- if (map.hasLayer(layers[i].layer)) {
- layerConfig += layers[i].layerCode;
- }
- }
- return layerConfig;
-}
-
-function setMapLayers(layerConfig) {
- var foundLayer = false;
- for (var i = 0; i < layers.length; i++) {
- if (layerConfig.indexOf(layers[i].layerCode) >= 0) {
- map.addLayer(layers[i].layer);
- foundLayer = true;
- } else {
- map.removeLayer(layers[i].layer);
- }
- }
- if (!foundLayer) {
- map.addLayer(layers[0].layer);
- }
-}
$(document).ready(function () {
- var map = createMap("map", {
- zoomControl: true,
- panZoomControl: false
+ var map = L.map("map", {
+ attributionControl: false,
+ zoomControl: false
+ }).addLayer(new L.OSM.Mapnik());
+
+ L.control.zoom({position: 'topright'})
+ .addTo(map);
+
+ $("#map").on("resized", function () {
+ map.invalidateSize();
});
if (OSM.home) {