Fix coordinate order on popover, clean up resolve_latlng
This commit is contained in:
parent
6a779db77b
commit
d229044ebf
@ -242,19 +242,27 @@ load_geojson("Streets", "./geojson/streets.json", "street", "blue", 0);
|
|||||||
|
|
||||||
L.control.scale().addTo(mymap);
|
L.control.scale().addTo(mymap);
|
||||||
|
|
||||||
|
function resolve_latlng(latlng, recenter = 0) {
|
||||||
|
latlng.lng = Math.round(latlng.lng);
|
||||||
|
latlng.lat = Math.round(latlng.lat);
|
||||||
|
return latlng;
|
||||||
|
}
|
||||||
|
|
||||||
function get_current_location_str() {
|
function get_current_location_str() {
|
||||||
var latlng = mymap.getCenter();
|
var latlng = resolve_latlng(mymap.getCenter());
|
||||||
return Math.round(latlng.lng) + "," + Math.round(latlng.lat) + "," + mymap.getZoom();
|
return latlng.lng + "," + latlng.lat + "," + mymap.getZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Important: Do not use mymap.setView, use this function instead */
|
/* Important: Do not use mymap.setView, use this function instead */
|
||||||
function jump_to(latlng, zoom = -1) {
|
function jump_to(latlng, zoom = -1) {
|
||||||
if (zoom == -1)
|
if (zoom == -1)
|
||||||
zoom = mymap.getZoom();
|
zoom = mymap.getZoom();
|
||||||
if (!editor_mode)
|
if (!editor_mode) {
|
||||||
document.location.hash = "#" + Math.round(latlng.lng) + "," + Math.round(latlng.lat) + "," + zoom;
|
pos = resolve_latlng(latlng);
|
||||||
else
|
document.location.hash = "#" + pos.lng + "," + pos.lat + "," + zoom;
|
||||||
|
} else {
|
||||||
mymap.setView(latlng, zoom);
|
mymap.setView(latlng, zoom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function jump_to_marker(e) {
|
function jump_to_marker(e) {
|
||||||
@ -351,8 +359,8 @@ function search(e) {
|
|||||||
|
|
||||||
if (item.feature.properties.name.match(regex)) {
|
if (item.feature.properties.name.match(regex)) {
|
||||||
el = document.createElement("li");
|
el = document.createElement("li");
|
||||||
zpos = layers._layers[i].layer._layers[item._leaflet_id].getCenter();
|
zpos = resolve_latlng(layers._layers[i].layer._layers[item._leaflet_id].getCenter());
|
||||||
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + Math.round(zpos.lat) + ',' + Math.round(zpos.lng) + '); jump_to(latLng2, ' + polyconf_show_cities + '); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
|
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos.lat + ',' + zpos.lng + '); jump_to(latLng2, ' + polyconf_show_cities + '); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
|
||||||
results.appendChild(el);
|
results.appendChild(el);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -422,7 +430,8 @@ function onMapClick(e) {
|
|||||||
if (current_feature) {
|
if (current_feature) {
|
||||||
popup.setLatLng(e.latlng).setContent("This is " + current_feature.properties.name + addinfo).openOn(mymap);
|
popup.setLatLng(e.latlng).setContent("This is " + current_feature.properties.name + addinfo).openOn(mymap);
|
||||||
} else {
|
} else {
|
||||||
popup.setLatLng(e.latlng).setContent("You clicked the map at " + e.latlng.toString() + addinfo).openOn(mymap);
|
pos = resolve_latlng(e.latlng);
|
||||||
|
popup.setLatLng(e.latlng).setContent("You clicked the map at " + pos.lng + "," + pos.lat + addinfo).openOn(mymap);
|
||||||
}
|
}
|
||||||
current_feature = null;
|
current_feature = null;
|
||||||
current_location = "";
|
current_location = "";
|
||||||
|
@ -10,12 +10,6 @@ if (editor_mode) {
|
|||||||
|
|
||||||
var edit_active = 0;
|
var edit_active = 0;
|
||||||
|
|
||||||
function resolve_latlng(latlng, recenter = 0) {
|
|
||||||
latlng.lng = Math.round(latlng.lng);
|
|
||||||
latlng.lat = Math.round(latlng.lat);
|
|
||||||
return latlng;
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_editing(dir = 1) {
|
function start_editing(dir = 1) {
|
||||||
// TODO: Check whether we already are in edit mode
|
// TODO: Check whether we already are in edit mode
|
||||||
// TODO: Detect whether we are cloner to the tail or the head, and issue Fwd or Bwd accordingly
|
// TODO: Detect whether we are cloner to the tail or the head, and issue Fwd or Bwd accordingly
|
||||||
|
Loading…
Reference in New Issue
Block a user