mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-25 00:08:25 -04:00
check that map exists on page before drawing it
This commit is contained in:
1 parent
890a21ddb2
commit
828e9d318a
2 files changed
+30
-26
No files matched your search
@@ -1,10 +1,12 @@
|
||||
mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>";
|
||||
mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png";
|
||||
if (document.getElementById("cropmap") !== null) {
|
||||
mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>";
|
||||
mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png";
|
||||
|
||||
L.Icon.Default.imagePath = '/assets'
|
||||
L.Icon.Default.imagePath = '/assets'
|
||||
|
||||
cropmap = L.map('cropmap').setView([0.0, -0.0], 2);
|
||||
showCropMap(cropmap);
|
||||
cropmap = L.map('cropmap').setView([0.0, -0.0], 2);
|
||||
showCropMap(cropmap);
|
||||
}
|
||||
|
||||
function showCropMap(cropmap) {
|
||||
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
places_base_path = "/places";
|
||||
mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>";
|
||||
mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png";
|
||||
nominatim_base_url = 'http://nominatim.openstreetmap.org/search/';
|
||||
nominatim_user_agent_email = "<%= Growstuff::Application.config.user_agent_email %>";
|
||||
if (document.getElementById("placesmap") !== null) {
|
||||
places_base_path = "/places";
|
||||
mapbox_map_id = "<%= Growstuff::Application.config.mapbox_map_id %>";
|
||||
mapbox_base_url = "https://c.tiles.mapbox.com/v3/" + mapbox_map_id + "/{z}/{x}/{y}.png";
|
||||
nominatim_base_url = 'http://nominatim.openstreetmap.org/search/';
|
||||
nominatim_user_agent_email = "<%= Growstuff::Application.config.user_agent_email %>";
|
||||
|
||||
L.Icon.Default.imagePath = '/assets'
|
||||
L.Icon.Default.imagePath = '/assets'
|
||||
|
||||
if (location.pathname === places_base_path) { //places index page
|
||||
placesmap = L.map('placesmap').setView([0.0, -0.0], 2);
|
||||
showMap(placesmap);
|
||||
} else { // specific place page
|
||||
place = location.pathname.replace(places_base_path + "/", '');
|
||||
nominatim_query_url = nominatim_base_url + place;
|
||||
nominatim_options = {
|
||||
format: "json",
|
||||
callback: "placeholder",
|
||||
limit: 1,
|
||||
email: nominatim_user_agent_email
|
||||
};
|
||||
$.getJSON(nominatim_query_url, nominatim_options, function(data) {
|
||||
placesmap = L.map('map').setView([data[0].lat, data[0].lon], 5);
|
||||
if (location.pathname === places_base_path) { //places index page
|
||||
placesmap = L.map('placesmap').setView([0.0, -0.0], 2);
|
||||
showMap(placesmap);
|
||||
})
|
||||
} else { // specific place page
|
||||
place = location.pathname.replace(places_base_path + "/", '');
|
||||
nominatim_query_url = nominatim_base_url + place;
|
||||
nominatim_options = {
|
||||
format: "json",
|
||||
callback: "placeholder",
|
||||
limit: 1,
|
||||
email: nominatim_user_agent_email
|
||||
};
|
||||
$.getJSON(nominatim_query_url, nominatim_options, function(data) {
|
||||
placesmap = L.map('map').setView([data[0].lat, data[0].lon], 5);
|
||||
showMap(placesmap);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function showMap(placesmap) {
|
||||
|
||||
Reference in new issue
Block a user