Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
mousewheezoom
Browse files Browse the repository at this point in the history
  • Loading branch information
astridx committed Jul 15, 2019
1 parent 788ecdc commit 5525154
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 49 deletions.
2 changes: 1 addition & 1 deletion dist/pkg-agosms.zip
2 changes: 1 addition & 1 deletion jorobo.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extension = agosms
version = 1.0.41
version = 1.0.42
source = src
target = package

Expand Down
1 change: 0 additions & 1 deletion src/media/mod_agosm/js/aggpxtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
15 changes: 14 additions & 1 deletion src/media/mod_agosm/js/agosm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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, ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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 &copy; <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors, ' +
'<a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>, ' +
'Imagery © <a href=\"http://mapbox.com\">Mapbox</a>';
'<a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>, ' +
'Imagery © <a href=\"http://mapbox.com\">Mapbox</a>';
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);
Original file line number Diff line number Diff line change
Expand Up @@ -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 © <a href="https://openstreetmap.org">OpenStreetMap</a> 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);
Original file line number Diff line number Diff line change
@@ -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);
11 changes: 11 additions & 0 deletions src/modules/mod_agosm/mod_agosm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="scrollwheelzoom"
type="radio"
label="MOD_AGOSM_SCROLLWHEELZOOM_LABEL"
description="MOD_AGOSM_NOWORLDWARP_SCROLLWHEELZOOM_DESC"
class="btn-group btn-group-yesno switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
type="list"
name="attrModule"
Expand Down
1 change: 1 addition & 0 deletions src/modules/mod_agosm/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<div style="
width:auto;
height:<?php echo $params->get('height', '400'); ?>px;"
data-scrollwheelzoom='<?php echo $params->get('scrollwheelzoom', '') ?>'
data-module-id="<?php echo $module->id; ?>"
data-no-world-warp="<?php echo $params->get('noWorldWarp', 0); ?>"
data-detect-retina="<?php echo $params->get('detectRetina', 0); ?>"
Expand Down
1 change: 1 addition & 0 deletions src/modules/mod_agosm/tmpl/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
width:auto;
height:<?php echo $params->get('height', '400'); ?>px;"
data-module-id="<?php echo $module->id; ?>"
data-scrollwheelzoom='<?php echo $params->get('scrollwheelzoom', '') ?>'

data-gpx_file_name="<?php echo $gpxfile; ?>"
data-startIconUrl="<?php echo $startIconUrl; ?>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -232,6 +245,7 @@ protected function getLayoutData()
'googlekey' => $this->googlekey,
'mapboxkey' => $this->mapboxkey,
'addressfields' => $this->addressfields,
'scrollwheelzoom' => $this->scrollwheelzoom,
'options' => $options,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
size="30"
showon="maptype:mapbox[OR]geocoder:mapbox"
/>
<field
name="scrollwheelzoom"
type="radio"
label="PLG_AGOSMSADDRESSMARKER_SRCOLLWHEELZOOM"
class="btn-group btn-group-yesno switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -59,5 +60,6 @@ class = 'agosmsaddressmarkerleafletmap'
data-lat='<?php echo $lat ?>'
data-lon='<?php echo $lon ?>'
data-mapboxkey='<?php echo $fieldParams->get('mapboxkey', '') ?>'
data-scrollwheelzoom='<?php echo $fieldParams->get('scrollwheelzoom', '') ?>'
>
</div>

0 comments on commit 5525154

Please sign in to comment.