1 $(document).ready(function () {
2 function remoteEditHandler(bbox, select) {
3 var left = bbox.getWest() - 0.0001;
4 var top = bbox.getNorth() + 0.0001;
5 var right = bbox.getEast() + 0.0001;
6 var bottom = bbox.getSouth() - 0.0001;
9 $("#linkloader").load(function () { loaded = true; });
19 if (select) query.select = select;
20 $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?" +
21 querystring.stringify(query));
23 setTimeout(function () {
24 if (!loaded) alert(I18n.t('site.index.remote_failed'));
30 var map = L.map("small_map", {
31 attributionControl: false,
33 }).addLayer(new L.OSM.Mapnik());
35 L.control.zoom({position: 'topright'})
38 $("#small_map").on("resized", function () {
42 var params = $("#small_map").data();
44 if (params.type == "changeset") {
45 bbox = L.latLngBounds([params.minlat, params.minlon],
46 [params.maxlat, params.maxlon]);
57 $("#browse_map .geolink").show();
59 $("a[data-editor=remote]").click(function () {
60 return remoteEditHandler(bbox);
63 updatelinks(map.getCenter(), 16, null, [[params.minlat, params.minlon],
64 [params.maxlat, params.maxlon]]);
65 } else if (params.type == "note") {
66 object = {type: params.type, id: params.id};
68 map.setView([params.lat, params.lon], 16);
70 L.marker([params.lat, params.lon], { icon: getUserIcon() }).addTo(map);
72 bbox = map.getBounds();
75 $("#browse_map .geolink").show();
77 $("a[data-editor=remote]").click(function () {
78 return remoteEditHandler(bbox);
81 updatelinks(params, 16, null,
82 bbox.getWest(), bbox.getSouth(),
83 bbox.getEast(), bbox.getNorth(),
86 $("#object_larger_map, #object_edit").hide();
88 object = {type: params.type, id: params.id};
90 if (!params.visible) {
91 object.version = params.version - 1;
94 addObjectToMap(object, map, {
96 callback: function(extent) {
98 $("#browse_map .geolink").show();
101 $("a.bbox[data-editor=remote]").click(function () {
102 return remoteEditHandler(extent);
105 $("a.object[data-editor=remote]").click(function () {
106 return remoteEditHandler(extent, params.type + params.id);
109 $("#object_larger_map").show();
110 $("#object_edit").show();
112 updatelinks(map.getCenter(), 16, null, extent, object);
114 $("#small_map").hide();
120 createMenu("area_edit", "area_edit_menu", "right");
121 createMenu("object_edit", "object_edit_menu", "right");