Extract function to add map attribution
This commit is contained in:
@@ -7,9 +7,6 @@
|
|||||||
App.Map.initializeMap(this);
|
App.Map.initializeMap(this);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
attributionPrefix: function() {
|
|
||||||
return '<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">Leaflet</a>';
|
|
||||||
},
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
App.Map.maps.forEach(function(map) {
|
App.Map.maps.forEach(function(map) {
|
||||||
map.off();
|
map.off();
|
||||||
@@ -19,12 +16,10 @@
|
|||||||
},
|
},
|
||||||
initializeMap: function(element) {
|
initializeMap: function(element) {
|
||||||
var addMarkerInvestments, centerData, clearFormfields, createMarker,
|
var addMarkerInvestments, centerData, clearFormfields, createMarker,
|
||||||
editable, getPopupContent, markerData, map, mapAttribution,
|
editable, getPopupContent, markerData, map, mapCenterLatLng, marker,
|
||||||
mapCenterLatLng, mapTilesProvider, marker, markerIcon, moveOrPlaceMarker,
|
markerIcon, moveOrPlaceMarker, openMarkerPopup, removeMarker,
|
||||||
openMarkerPopup, removeMarker, removeMarkerSelector, updateFormfields;
|
removeMarkerSelector, updateFormfields;
|
||||||
App.Map.cleanInvestmentCoordinates(element);
|
App.Map.cleanInvestmentCoordinates(element);
|
||||||
mapTilesProvider = $(element).data("map-tiles-provider");
|
|
||||||
mapAttribution = $(element).data("map-tiles-provider-attribution");
|
|
||||||
removeMarkerSelector = $(element).data("marker-remove-selector");
|
removeMarkerSelector = $(element).data("marker-remove-selector");
|
||||||
addMarkerInvestments = $(element).data("marker-investments-coordinates");
|
addMarkerInvestments = $(element).data("marker-investments-coordinates");
|
||||||
editable = $(element).data("marker-editable");
|
editable = $(element).data("marker-editable");
|
||||||
@@ -95,11 +90,8 @@
|
|||||||
centerData = App.Map.centerData(element);
|
centerData = App.Map.centerData(element);
|
||||||
mapCenterLatLng = new L.LatLng(centerData.lat, centerData.long);
|
mapCenterLatLng = new L.LatLng(centerData.lat, centerData.long);
|
||||||
map = L.map(element.id, { scrollWheelZoom: false }).setView(mapCenterLatLng, centerData.zoom);
|
map = L.map(element.id, { scrollWheelZoom: false }).setView(mapCenterLatLng, centerData.zoom);
|
||||||
map.attributionControl.setPrefix(App.Map.attributionPrefix());
|
|
||||||
App.Map.maps.push(map);
|
App.Map.maps.push(map);
|
||||||
L.tileLayer(mapTilesProvider, {
|
App.Map.addAttribution(map);
|
||||||
attribution: mapAttribution
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
markerData = App.Map.markerData(element);
|
markerData = App.Map.markerData(element);
|
||||||
if (markerData.lat && markerData.long && !addMarkerInvestments) {
|
if (markerData.lat && markerData.long && !addMarkerInvestments) {
|
||||||
@@ -124,6 +116,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
attributionPrefix: function() {
|
||||||
|
return '<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">Leaflet</a>';
|
||||||
|
},
|
||||||
markerData: function(element) {
|
markerData: function(element) {
|
||||||
var dataCoordinates, formCoordinates, inputs, latitude, longitude;
|
var dataCoordinates, formCoordinates, inputs, latitude, longitude;
|
||||||
inputs = App.Map.coordinatesInputs(element);
|
inputs = App.Map.coordinatesInputs(element);
|
||||||
@@ -191,6 +186,16 @@
|
|||||||
$(element).attr("data-marker-investments-coordinates", clean_markers);
|
$(element).attr("data-marker-investments-coordinates", clean_markers);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
addAttribution: function(map) {
|
||||||
|
var element, mapAttribution, mapTilesProvider;
|
||||||
|
|
||||||
|
element = map._container;
|
||||||
|
mapTilesProvider = $(element).data("map-tiles-provider");
|
||||||
|
mapAttribution = $(element).data("map-tiles-provider-attribution");
|
||||||
|
|
||||||
|
map.attributionControl.setPrefix(App.Map.attributionPrefix());
|
||||||
|
L.tileLayer(mapTilesProvider, { attribution: mapAttribution }).addTo(map);
|
||||||
|
},
|
||||||
validZoom: function(zoom) {
|
validZoom: function(zoom) {
|
||||||
return App.Map.isNumeric(zoom);
|
return App.Map.isNumeric(zoom);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user