diff --git a/dist/pkg-agosms.zip b/dist/pkg-agosms.zip index a3cd667c..3805c896 120000 --- a/dist/pkg-agosms.zip +++ b/dist/pkg-agosms.zip @@ -1 +1 @@ -/home/astrid/git/joomla-development/pkg_agosms/dist/pkg-agosms-1.0.38.zip \ No newline at end of file +/home/astrid/git/joomla-development/pkg_agosms/dist/pkg-agosms-1.0.41.zip \ No newline at end of file diff --git a/jorobo.ini b/jorobo.ini index 363e0bca..19e06526 100644 --- a/jorobo.ini +++ b/jorobo.ini @@ -1,5 +1,5 @@ extension = agosms -version = 1.0.41 +version = 1.0.42 source = src target = package diff --git a/src/media/mod_agosm/js/aggpxtrack.js b/src/media/mod_agosm/js/aggpxtrack.js index 59e10f31..12fd2503 100644 --- a/src/media/mod_agosm/js/aggpxtrack.js +++ b/src/media/mod_agosm/js/aggpxtrack.js @@ -17,7 +17,6 @@ document.addEventListener('DOMContentLoaded', function () { window['mymap' + moduleId].fitBounds([[0, 0],[0, 0]]); for (var i = 0; i < gpxfilenames.length; i++) { - console.log(gpxfilenames[i]); new L.GPX(gpxfilenames[i], { marker_options: { diff --git a/src/media/mod_agosm/js/agosm.js b/src/media/mod_agosm/js/agosm.js index 8b9aefad..dce55f62 100644 --- a/src/media/mod_agosm/js/agosm.js +++ b/src/media/mod_agosm/js/agosm.js @@ -5,6 +5,7 @@ document.addEventListener('DOMContentLoaded', function () { [].forEach.call(leafletmapsMod, function (element) { // Create map with worldWarp + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); var noWorldWarp = element.getAttribute('data-no-world-warp'); var moduleId = element.getAttribute('data-module-id'); var detectRetina = element.getAttribute('data-detect-retina'); @@ -72,12 +73,24 @@ document.addEventListener('DOMContentLoaded', function () { var specialcustomfieldpins = JSON.parse(element.getAttribute('data-specialcustomfieldpins')); } - if (noWorldWarp === "1") + if (noWorldWarp === "1" && scrollwheelzoom === "0") { + window['mymap' + moduleId] = new L.Map('map' + moduleId, {worldCopyJump: false, scrollWheelZoom: false, maxBounds: [ [82, -180], [-82, 180] ]}).setView(lonlat, zoom); + } else if (noWorldWarp === "1" && scrollwheelzoom === "1") { window['mymap' + moduleId] = new L.Map('map' + moduleId, {worldCopyJump: false, maxBounds: [ [82, -180], [-82, 180] ]}).setView(lonlat, zoom); } else { window['mymap' + moduleId] = new L.Map('map' + moduleId, {worldCopyJump: true}).setView(lonlat, zoom); } + + // Add Scrollwheele Listener, so that you can activate it on mouse click + window['mymap' + moduleId].on('click', function () { + if (window['mymap' + moduleId].scrollWheelZoom.enabled()) { + window['mymap' + moduleId].scrollWheelZoom.disable(); + } else + { + window['mymap' + moduleId].scrollWheelZoom.enable(); + } + }); // Baselayer var nowarp = "noWrap: false, "; diff --git a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-google.js b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-google.js index acf317eb..d050c78b 100644 --- a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-google.js +++ b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-google.js @@ -5,26 +5,24 @@ document.addEventListener('DOMContentLoaded', function () { [].forEach.call(leafletmaps, function (element) { var unique = element.getAttribute('data-unique'); - var lat = element.getAttribute('data-lat'); - var lon = element.getAttribute('data-lon'); + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); - map = new L.Map('map' + unique); + // Initialize the Map if needed + var container = L.DomUtil.get('map' + unique); + if (!container.children.length > 0) { + if (scrollwheelzoom === "0") + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: false}); + } else + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: true}); + } + } var googleLayer = L.gridLayer.googleMutant({ type: 'roadmap' - }).addTo(map); - - - // For all maps [end] - - try { - map.setView(new L.LatLng(lat, lon), 13); - var marker = L.marker([lat, lon]).addTo(map); - } catch (e) { - map.setView(new L.LatLng(0, 0), 13); - var marker = L.marker([0, 0]).addTo(map); - console.log(e); - } + }).addTo(window['map' + unique]); }); + // For all maps [end] }, false); \ No newline at end of file diff --git a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-mapbox.js b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-mapbox.js index e8263082..2853561b 100644 --- a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-mapbox.js +++ b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-mapbox.js @@ -5,27 +5,28 @@ document.addEventListener('DOMContentLoaded', function () { [].forEach.call(leafletmaps, function (element) { var unique = element.getAttribute('data-unique'); - var lat = element.getAttribute('data-lat'); - var lon = element.getAttribute('data-lon'); + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); var mapboxkey = element.getAttribute('data-mapboxkey'); - console.log(mapboxkey); - map = new L.Map('map' + unique); + // Initialize the Map if needed + var container = L.DomUtil.get('map' + unique); + if (!container.children.length > 0) { + if (scrollwheelzoom === "0") + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: false}); + } else + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: true}); + } + } + var osmUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + mapboxkey; var osmAttrib = 'Map data © OpenStreetMap contributors, ' + - 'CC-BY-SA, ' + - 'Imagery © Mapbox'; + 'CC-BY-SA, ' + + 'Imagery © Mapbox'; var osm = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 12, attribution: osmAttrib, id: 'mapbox.streets'}); - map.addLayer(osm); // For all maps [end] - - try { - map.setView(new L.LatLng(lat, lon), 13); - var marker = L.marker([lat, lon]).addTo(map); - } catch (e) { - map.setView(new L.LatLng(0, 0), 13); - var marker = L.marker([0, 0]).addTo(map); - console.log(e); - } + window['map' + unique].addLayer(osm); }); + // For all maps [end] }, false); \ No newline at end of file diff --git a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-openstreetmap.js b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-openstreetmap.js index 3cc2968e..02564c68 100644 --- a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-openstreetmap.js +++ b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-openstreetmap.js @@ -5,23 +5,25 @@ document.addEventListener('DOMContentLoaded', function () { [].forEach.call(leafletmaps, function (element) { var unique = element.getAttribute('data-unique'); - var lat = element.getAttribute('data-lat'); - var lon = element.getAttribute('data-lon'); + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); + + // Initialize the Map if needed + var container = L.DomUtil.get('map' + unique); + if (!container.children.length > 0) { + if (scrollwheelzoom === "0") + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: false}); + } else + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: true}); + } + } - map = new L.Map('map' + unique); var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var osmAttrib = 'Map data © OpenStreetMap contributors'; var osm = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 12, attribution: osmAttrib}); - map.addLayer(osm); // For all maps [end] - - try { - map.setView(new L.LatLng(lat, lon), 13); - var marker = L.marker([lat, lon]).addTo(map); - } catch (e) { - map.setView(new L.LatLng(0, 0), 13); - var marker = L.marker([0, 0]).addTo(map); - console.log(e); - } + window['map' + unique].addLayer(osm); }); + // For all maps [end] }, false); \ No newline at end of file diff --git a/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker.js b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker.js new file mode 100644 index 00000000..e782f986 --- /dev/null +++ b/src/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker.js @@ -0,0 +1,47 @@ +document.addEventListener('DOMContentLoaded', function () { + var leafletmaps = document.querySelectorAll('.agosmsaddressmarkerleafletmap'); + + // For all maps [start] + [].forEach.call(leafletmaps, function (element) { + + var unique = element.getAttribute('data-unique'); + var lat = element.getAttribute('data-lat'); + var lon = element.getAttribute('data-lon'); + var scrollwheelzoom = element.getAttribute('data-scrollwheelzoom'); + var mapboxkey = element.getAttribute('data-mapboxkey'); + + // Initialize the Map if needed + var container = L.DomUtil.get('map' + unique); + if (!container.children.length > 0) { + if (scrollwheelzoom === "0") + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: false}); + } else + { + window['map' + unique] = new L.Map('map' + unique, {scrollWheelZoom: true}); + } + } + + // Add Scrollwheele Listener, so that you can activate it on mouse click + window['map' + unique].on('click', function () { + if (window['map' + unique].scrollWheelZoom.enabled()) { + window['map' + unique].scrollWheelZoom.disable(); + } else + { + window['map' + unique].scrollWheelZoom.enable(); + } + }); + + // Add Marker if possible - fallback cords 0,0 + try { + window['map' + unique].setView(new L.LatLng(lat, lon), 13); + var marker = L.marker([lat, lon]).addTo(window['map' + unique]); + } catch (e) { + window['map' + unique].setView(new L.LatLng(0, 0), 13); + var marker = L.marker([0, 0]).addTo(window['map' + unique]); + console.log(e); + } + }); + // For all maps [end] + +}, false); \ No newline at end of file diff --git a/src/modules/mod_agosm/mod_agosm.xml b/src/modules/mod_agosm/mod_agosm.xml index 232e249c..afa97da4 100644 --- a/src/modules/mod_agosm/mod_agosm.xml +++ b/src/modules/mod_agosm/mod_agosm.xml @@ -229,6 +229,17 @@ + + + + ' data-module-id="id; ?>" data-no-world-warp="get('noWorldWarp', 0); ?>" data-detect-retina="get('detectRetina', 0); ?>" diff --git a/src/modules/mod_agosm/tmpl/upload.php b/src/modules/mod_agosm/tmpl/upload.php index af2d2969..a40eb727 100644 --- a/src/modules/mod_agosm/tmpl/upload.php +++ b/src/modules/mod_agosm/tmpl/upload.php @@ -92,6 +92,7 @@ width:auto; height:get('height', '400'); ?>px;" data-module-id="id; ?>" + data-scrollwheelzoom='get('scrollwheelzoom', '') ?>' data-gpx_file_name="" data-startIconUrl="" diff --git a/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php b/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php index 0eaca732..9c0c346f 100644 --- a/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php +++ b/src/plugins/fields/agosmsaddressmarker/field/agosmsaddressmarker.php @@ -81,6 +81,14 @@ class JFormFieldAgosmsaddressmarker extends JFormFieldText * @since 1.0.40 */ protected $addressfields; + + /** + * The name of the addressfields field. + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $scrollwheelzoom; /** * Method to get certain otherwise inaccessible properties from the form field object. @@ -132,6 +140,7 @@ public function setup(SimpleXMLElement $element, $value, $group = null) $this->googlekey = (string) $this->element['googlekey']; $this->mapboxkey = (string) $this->element['mapboxkey']; $this->addressfields = (string) $this->element['addressfields']; + $this->scrollwheelzoom = (string) $this->element['scrollwheelzoom']; } return $result; @@ -175,6 +184,10 @@ public function __set($name, $value) $this->addressfields = (string) $value; break; + case 'scrollwheelzoom': + $this->scrollwheelzoom = (string) $value; + break; + default: parent::__set($name, $value); } @@ -232,6 +245,7 @@ protected function getLayoutData() 'googlekey' => $this->googlekey, 'mapboxkey' => $this->mapboxkey, 'addressfields' => $this->addressfields, + 'scrollwheelzoom' => $this->scrollwheelzoom, 'options' => $options, ); diff --git a/src/plugins/fields/agosmsaddressmarker/params/agosmsaddressmarker.xml b/src/plugins/fields/agosmsaddressmarker/params/agosmsaddressmarker.xml index 1ae34855..c7e0968e 100644 --- a/src/plugins/fields/agosmsaddressmarker/params/agosmsaddressmarker.xml +++ b/src/plugins/fields/agosmsaddressmarker/params/agosmsaddressmarker.xml @@ -56,6 +56,16 @@ size="30" showon="maptype:mapbox[OR]geocoder:mapbox" /> + + + + diff --git a/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php b/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php index a5c70df4..189beabe 100644 --- a/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php +++ b/src/plugins/fields/agosmsaddressmarker/tmpl/agosmsaddressmarker.php @@ -32,6 +32,7 @@ { $document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker-openstreetmap.js'); } +$document->addScript(JURI::root(true) . '/media/plg_fields_agosmsaddressmarker/js/site-agosmsaddressmarker.js'); // We need this for list views $unique = $field->id . '_' . uniqid(); @@ -59,5 +60,6 @@ class = 'agosmsaddressmarkerleafletmap' data-lat='' data-lon='' data-mapboxkey='get('mapboxkey', '') ?>' + data-scrollwheelzoom='get('scrollwheelzoom', '') ?>' >