Merge pull request #1633 from Terny22/improvement/maps-scroll-zooming-setting
Added 'Disable scroll zooming' setting for all map types
This commit is contained in:
commit
bad855027b
File diff suppressed because one or more lines are too long
@ -19,7 +19,7 @@ var gmGlobals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class TbGoogleMap {
|
export default class TbGoogleMap {
|
||||||
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, minZoomLevel, gmApiKey, gmDefaultMapType) {
|
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, gmApiKey, gmDefaultMapType) {
|
||||||
|
|
||||||
var tbMap = this;
|
var tbMap = this;
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
@ -44,7 +44,7 @@ export default class TbGoogleMap {
|
|||||||
function initGoogleMap() {
|
function initGoogleMap() {
|
||||||
|
|
||||||
tbMap.map = new google.maps.Map($containerElement[0], { // eslint-disable-line no-undef
|
tbMap.map = new google.maps.Map($containerElement[0], { // eslint-disable-line no-undef
|
||||||
scrollwheel: true,
|
scrollwheel: !disableScrollZooming,
|
||||||
mapTypeId: getGoogleMapTypeId(tbMap.defaultMapType),
|
mapTypeId: getGoogleMapTypeId(tbMap.defaultMapType),
|
||||||
zoom: tbMap.defaultZoomLevel || 8
|
zoom: tbMap.defaultZoomLevel || 8
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const maxZoom = 4;
|
|||||||
|
|
||||||
export default class TbImageMap {
|
export default class TbImageMap {
|
||||||
|
|
||||||
constructor(ctx, $containerElement, utils, initCallback, imageUrl, posFunction, imageEntityAlias, imageUrlAttribute) {
|
constructor(ctx, $containerElement, utils, initCallback, imageUrl, disableScrollZooming, posFunction, imageEntityAlias, imageUrlAttribute) {
|
||||||
|
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
@ -34,6 +34,7 @@ export default class TbImageMap {
|
|||||||
this.height = 0;
|
this.height = 0;
|
||||||
this.markers = [];
|
this.markers = [];
|
||||||
this.initCallback = initCallback;
|
this.initCallback = initCallback;
|
||||||
|
this.disableScrollZooming = disableScrollZooming;
|
||||||
|
|
||||||
if (angular.isDefined(posFunction) && posFunction.length > 0) {
|
if (angular.isDefined(posFunction) && posFunction.length > 0) {
|
||||||
try {
|
try {
|
||||||
@ -165,6 +166,7 @@ export default class TbImageMap {
|
|||||||
this.map = L.map(this.$containerElement[0], {
|
this.map = L.map(this.$containerElement[0], {
|
||||||
minZoom: 1,
|
minZoom: 1,
|
||||||
maxZoom: maxZoom,
|
maxZoom: maxZoom,
|
||||||
|
scrollWheelZoom: !this.disableScrollZooming,
|
||||||
center: center,
|
center: center,
|
||||||
zoom: 1,
|
zoom: 1,
|
||||||
crs: L.CRS.Simple,
|
crs: L.CRS.Simple,
|
||||||
|
|||||||
@ -78,28 +78,29 @@ export default class TbMapWidgetV2 {
|
|||||||
tbMap.tooltipActionsMap[descriptor.name] = descriptor;
|
tbMap.tooltipActionsMap[descriptor.name] = descriptor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let openStreetMapProvider = {};
|
||||||
if (mapProvider === 'google-map') {
|
if (mapProvider === 'google-map') {
|
||||||
this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType);
|
this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType);
|
||||||
} else if (mapProvider === 'openstreet-map') {
|
} else if (mapProvider === 'openstreet-map') {
|
||||||
let openStreetMapProvider = {};
|
|
||||||
if (settings.useCustomProvider && settings.customProviderTileUrl) {
|
if (settings.useCustomProvider && settings.customProviderTileUrl) {
|
||||||
openStreetMapProvider.name = settings.customProviderTileUrl;
|
openStreetMapProvider.name = settings.customProviderTileUrl;
|
||||||
openStreetMapProvider.isCustom = true;
|
openStreetMapProvider.isCustom = true;
|
||||||
} else {
|
} else {
|
||||||
openStreetMapProvider.name = settings.mapProvider;
|
openStreetMapProvider.name = settings.mapProvider;
|
||||||
}
|
}
|
||||||
|
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider);
|
||||||
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, openStreetMapProvider);
|
|
||||||
} else if (mapProvider === 'here') {
|
} else if (mapProvider === 'here') {
|
||||||
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, settings.mapProvider, settings.credentials);
|
openStreetMapProvider.name = settings.mapProvider;
|
||||||
|
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider, settings.credentials);
|
||||||
} else if (mapProvider === 'image-map') {
|
} else if (mapProvider === 'image-map') {
|
||||||
this.map = new TbImageMap(this.ctx, $element, this.utils, initCallback,
|
this.map = new TbImageMap(this.ctx, $element, this.utils, initCallback,
|
||||||
settings.mapImageUrl,
|
settings.mapImageUrl,
|
||||||
|
settings.disableScrollZooming,
|
||||||
settings.posFunction,
|
settings.posFunction,
|
||||||
settings.imageEntityAlias,
|
settings.imageEntityAlias,
|
||||||
settings.imageUrlAttribute);
|
settings.imageUrlAttribute);
|
||||||
} else if (mapProvider === 'tencent-map') {
|
} else if (mapProvider === 'tencent-map') {
|
||||||
this.map = new TbTencentMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType);
|
this.map = new TbTencentMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -938,6 +939,11 @@ const commonMapSettingsSchema =
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"disableScrollZooming": {
|
||||||
|
"title": "Disable scroll zooming",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"latKeyName": {
|
"latKeyName": {
|
||||||
"title": "Latitude key name",
|
"title": "Latitude key name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -1078,6 +1084,7 @@ const commonMapSettingsSchema =
|
|||||||
"form": [
|
"form": [
|
||||||
"defaultZoomLevel",
|
"defaultZoomLevel",
|
||||||
"fitMapBounds",
|
"fitMapBounds",
|
||||||
|
"disableScrollZooming",
|
||||||
"latKeyName",
|
"latKeyName",
|
||||||
"lngKeyName",
|
"lngKeyName",
|
||||||
"showLabel",
|
"showLabel",
|
||||||
@ -1189,6 +1196,11 @@ const imageMapSettingsSchema =
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
|
"disableScrollZooming": {
|
||||||
|
"title": "Disable scroll zooming",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"xPosKeyName": {
|
"xPosKeyName": {
|
||||||
"title": "X position key name",
|
"title": "X position key name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -1306,6 +1318,7 @@ const imageMapSettingsSchema =
|
|||||||
},
|
},
|
||||||
"imageEntityAlias",
|
"imageEntityAlias",
|
||||||
"imageUrlAttribute",
|
"imageUrlAttribute",
|
||||||
|
"disableScrollZooming",
|
||||||
"xPosKeyName",
|
"xPosKeyName",
|
||||||
"yPosKeyName",
|
"yPosKeyName",
|
||||||
"showLabel",
|
"showLabel",
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import 'leaflet-providers';
|
|||||||
|
|
||||||
export default class TbOpenStreetMap {
|
export default class TbOpenStreetMap {
|
||||||
|
|
||||||
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, minZoomLevel, mapProvider, credentials) {
|
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, mapProvider, credentials) {
|
||||||
|
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
this.defaultZoomLevel = defaultZoomLevel;
|
this.defaultZoomLevel = defaultZoomLevel;
|
||||||
@ -33,13 +33,17 @@ export default class TbOpenStreetMap {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapProvider.startsWith("HERE.")) {
|
if (mapProvider.name.startsWith("HERE.")) {
|
||||||
credentials.app_id = credentials.app_id || "AhM6TzD9ThyK78CT3ptx";
|
credentials.app_id = credentials.app_id || "AhM6TzD9ThyK78CT3ptx";
|
||||||
credentials.app_code = credentials.app_code || "p6NPiITB3Vv0GMUFnkLOOg";
|
credentials.app_code = credentials.app_code || "p6NPiITB3Vv0GMUFnkLOOg";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.map = L.map($containerElement[0]).setView([0, 0], this.defaultZoomLevel || 8);
|
this.map = L.map($containerElement[0]).setView([0, 0], this.defaultZoomLevel || 8);
|
||||||
|
|
||||||
|
if (disableScrollZooming) {
|
||||||
|
this.map.scrollWheelZoom.disable();
|
||||||
|
}
|
||||||
|
|
||||||
var tileLayer = mapProvider.isCustom ? L.tileLayer(mapProvider.name) : L.tileLayer.provider(mapProvider.name, credentials);
|
var tileLayer = mapProvider.isCustom ? L.tileLayer(mapProvider.name) : L.tileLayer.provider(mapProvider.name, credentials);
|
||||||
tileLayer.addTo(this.map);
|
tileLayer.addTo(this.map);
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ var tmGlobals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class TbTencentMap {
|
export default class TbTencentMap {
|
||||||
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, minZoomLevel, tmApiKey, tmDefaultMapType) {
|
constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, tmApiKey, tmDefaultMapType) {
|
||||||
var tbMap = this;
|
var tbMap = this;
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
this.defaultZoomLevel = defaultZoomLevel;
|
this.defaultZoomLevel = defaultZoomLevel;
|
||||||
@ -42,7 +42,7 @@ export default class TbTencentMap {
|
|||||||
|
|
||||||
function initTencentMap() {
|
function initTencentMap() {
|
||||||
tbMap.map = new qq.maps.Map($containerElement[0], { // eslint-disable-line no-undef
|
tbMap.map = new qq.maps.Map($containerElement[0], { // eslint-disable-line no-undef
|
||||||
scrollwheel: true,
|
scrollwheel: !disableScrollZooming,
|
||||||
mapTypeId: getTencentMapTypeId(tbMap.defaultMapType),
|
mapTypeId: getTencentMapTypeId(tbMap.defaultMapType),
|
||||||
zoom: tbMap.defaultZoomLevel || 8
|
zoom: tbMap.defaultZoomLevel || 8
|
||||||
});
|
});
|
||||||
|
|||||||
@ -264,7 +264,7 @@ function tripAnimationController($document, $scope, $log, $http, $timeout, $filt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vm.dontFitMapBounds = vm.ctx.settings.fitMapBounds === false;
|
vm.dontFitMapBounds = vm.ctx.settings.fitMapBounds === false;
|
||||||
vm.map = new TbOpenStreetMap(vm.ctx.$element, vm.utils, initCallback, vm.defaultZoomLevel, vm.dontFitMapBounds, null, vm.staticSettings.mapProvider);
|
vm.map = new TbOpenStreetMap(vm.ctx.$element, vm.utils, initCallback, vm.defaultZoomLevel, vm.dontFitMapBounds, vm.staticSettings.disableScrollZooming, null, vm.staticSettings.mapProvider);
|
||||||
vm.map.bounds = vm.map.createBounds();
|
vm.map.bounds = vm.map.createBounds();
|
||||||
vm.map.invalidateSize(true);
|
vm.map.invalidateSize(true);
|
||||||
vm.map.bounds = vm.map.createBounds();
|
vm.map.bounds = vm.map.createBounds();
|
||||||
@ -284,7 +284,8 @@ function tripAnimationController($document, $scope, $log, $http, $timeout, $filt
|
|||||||
staticSettings.disabledButtonColor = tinycolor(vm.widgetConfig.color).setAlpha(0.3).toRgbString();
|
staticSettings.disabledButtonColor = tinycolor(vm.widgetConfig.color).setAlpha(0.3).toRgbString();
|
||||||
staticSettings.polygonColor = tinycolor(vm.ctx.settings.polygonColor).toHexString();
|
staticSettings.polygonColor = tinycolor(vm.ctx.settings.polygonColor).toHexString();
|
||||||
staticSettings.polygonStrokeColor = tinycolor(vm.ctx.settings.polygonStrokeColor).toHexString();
|
staticSettings.polygonStrokeColor = tinycolor(vm.ctx.settings.polygonStrokeColor).toHexString();
|
||||||
staticSettings.mapProvider = vm.ctx.settings.mapProvider || "OpenStreetMap.Mapnik";
|
staticSettings.mapProvider = vm.ctx.settings.mapProvider ? {name: vm.ctx.settings.mapProvider} : {name: "OpenStreetMap.Mapnik"};
|
||||||
|
staticSettings.disableScrollZooming = vm.ctx.settings.disableScrollZooming || false;
|
||||||
staticSettings.latKeyName = vm.ctx.settings.latKeyName || "latitude";
|
staticSettings.latKeyName = vm.ctx.settings.latKeyName || "latitude";
|
||||||
staticSettings.lngKeyName = vm.ctx.settings.lngKeyName || "longitude";
|
staticSettings.lngKeyName = vm.ctx.settings.lngKeyName || "longitude";
|
||||||
staticSettings.polKeyName = vm.ctx.settings.polKeyName || "coordinates";
|
staticSettings.polKeyName = vm.ctx.settings.polKeyName || "coordinates";
|
||||||
@ -328,6 +329,12 @@ function tripAnimationController($document, $scope, $log, $http, $timeout, $filt
|
|||||||
iconSize: [30, 30],
|
iconSize: [30, 30],
|
||||||
iconAnchor: [15, 15]
|
iconAnchor: [15, 15]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (vm.ctx.settings.useCustomProvider && vm.ctx.settings.customProviderTileUrl) {
|
||||||
|
staticSettings.mapProvider.name = vm.ctx.settings.customProviderTileUrl;
|
||||||
|
staticSettings.mapProvider.isCustom = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (angular.isDefined(vm.ctx.settings.markerImage)) {
|
if (angular.isDefined(vm.ctx.settings.markerImage)) {
|
||||||
staticSettings.icon = L.icon({
|
staticSettings.icon = L.icon({
|
||||||
iconUrl: vm.ctx.settings.markerImage,
|
iconUrl: vm.ctx.settings.markerImage,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user