Merge pull request #3722 from vvlladd28/bug/map/fit-bound

Fixed fit bounds marker is disabled covered all markers
This commit is contained in:
Igor Kulikov 2020-11-16 09:34:05 +02:00 committed by GitHub
commit c1737d0de3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 10 deletions

View File

@ -487,7 +487,8 @@ export default abstract class LeafletMap {
} }
const mapBounds = this.map.getBounds(); const mapBounds = this.map.getBounds();
if (bounds.isValid() && (!this.bounds || !this.bounds.isValid() || !this.bounds.equals(bounds) && !mapBounds.contains(bounds))) { if (bounds.isValid() && (!this.bounds || !this.bounds.isValid() || !this.bounds.equals(bounds)
&& this.options.fitMapBounds ? !mapBounds.contains(bounds) : false)) {
this.bounds = bounds; this.bounds = bounds;
this.fitBounds(bounds); this.fitBounds(bounds);
} }

View File

@ -20,6 +20,7 @@ import { EntityType } from '@shared/models/entity-type.models';
import tinycolor from 'tinycolor2'; import tinycolor from 'tinycolor2';
export const DEFAULT_MAP_PAGE_SIZE = 16384; export const DEFAULT_MAP_PAGE_SIZE = 16384;
export const DEFAULT_ZOOM_LEVEL = 8;
export type GenericFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string; export type GenericFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string;
export type MarkerImageFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string; export type MarkerImageFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string;
@ -229,7 +230,6 @@ export const defaultSettings: any = {
strokeWeight: 2, strokeWeight: 2,
strokeOpacity: 1.0, strokeOpacity: 1.0,
initCallback: () => { }, initCallback: () => { },
defaultZoomLevel: 8,
disableScrollZooming: false, disableScrollZooming: false,
minZoomLevel: 16, minZoomLevel: 16,
credentials: '', credentials: '',

View File

@ -17,7 +17,7 @@
import L from 'leaflet'; import L from 'leaflet';
import LeafletMap from '../leaflet-map'; import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models'; import { DEFAULT_ZOOM_LEVEL, UnitedMapSettings } from '../map-models';
import 'leaflet.gridlayer.googlemutant'; import 'leaflet.gridlayer.googlemutant';
import { ResourcesService } from '@core/services/resources.service'; import { ResourcesService } from '@core/services/resources.service';
import { WidgetContext } from '@home/models/widget-component.models'; import { WidgetContext } from '@home/models/widget-component.models';
@ -39,7 +39,7 @@ export class GoogleMap extends LeafletMap {
const map = L.map($container, { const map = L.map($container, {
attributionControl: false, attributionControl: false,
editable: !!options.editablePolygon editable: !!options.editablePolygon
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL);
(L.gridLayer as any).googleMutant({ (L.gridLayer as any).googleMutant({
type: options?.gmDefaultMapType || 'roadmap' type: options?.gmDefaultMapType || 'roadmap'
}).addTo(map); }).addTo(map);

View File

@ -16,7 +16,7 @@
import L from 'leaflet'; import L from 'leaflet';
import LeafletMap from '../leaflet-map'; import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models'; import { DEFAULT_ZOOM_LEVEL, UnitedMapSettings } from '../map-models';
import { WidgetContext } from '@home/models/widget-component.models'; import { WidgetContext } from '@home/models/widget-component.models';
export class HEREMap extends LeafletMap { export class HEREMap extends LeafletMap {
@ -24,7 +24,7 @@ export class HEREMap extends LeafletMap {
super(ctx, $container, options); super(ctx, $container, options);
const map = L.map($container, { const map = L.map($container, {
editable: !!options.editablePolygon editable: !!options.editablePolygon
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL);
const tileLayer = (L.tileLayer as any).provider(options.mapProviderHere || 'HERE.normalDay', options.credentials); const tileLayer = (L.tileLayer as any).provider(options.mapProviderHere || 'HERE.normalDay', options.credentials);
tileLayer.addTo(map); tileLayer.addTo(map);
super.initSettings(options); super.initSettings(options);

View File

@ -16,7 +16,7 @@
import L from 'leaflet'; import L from 'leaflet';
import LeafletMap from '../leaflet-map'; import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models'; import { DEFAULT_ZOOM_LEVEL, UnitedMapSettings } from '../map-models';
import { WidgetContext } from '@home/models/widget-component.models'; import { WidgetContext } from '@home/models/widget-component.models';
export class OpenStreetMap extends LeafletMap { export class OpenStreetMap extends LeafletMap {
@ -24,7 +24,7 @@ export class OpenStreetMap extends LeafletMap {
super(ctx, $container, options); super(ctx, $container, options);
const map = L.map($container, { const map = L.map($container, {
editable: !!options.editablePolygon editable: !!options.editablePolygon
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL);
let tileLayer; let tileLayer;
if (options.useCustomProvider) { if (options.useCustomProvider) {
tileLayer = L.tileLayer(options.customProviderTileUrl); tileLayer = L.tileLayer(options.customProviderTileUrl);

View File

@ -17,7 +17,7 @@
import L from 'leaflet'; import L from 'leaflet';
import LeafletMap from '../leaflet-map'; import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models'; import { DEFAULT_ZOOM_LEVEL, UnitedMapSettings } from '../map-models';
import { WidgetContext } from '@home/models/widget-component.models'; import { WidgetContext } from '@home/models/widget-component.models';
export class TencentMap extends LeafletMap { export class TencentMap extends LeafletMap {
@ -26,7 +26,7 @@ export class TencentMap extends LeafletMap {
const txUrl = 'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0'; const txUrl = 'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0';
const map = L.map($container, { const map = L.map($container, {
editable: !!options.editablePolygon editable: !!options.editablePolygon
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL);
const txLayer = L.tileLayer(txUrl, { const txLayer = L.tileLayer(txUrl, {
subdomains: '0123', subdomains: '0123',
tms: true, tms: true,