Browse Source
Merge pull request #3722 from vvlladd28/bug/map/fit-bound
Fixed fit bounds marker is disabled covered all markers
pull/3745/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
11 additions and
10 deletions
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/google-map.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/here-map.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/tencent-map.ts
|
|
|
@ -487,7 +487,8 @@ export default abstract class LeafletMap { |
|
|
|
} |
|
|
|
|
|
|
|
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.fitBounds(bounds); |
|
|
|
} |
|
|
|
|
|
|
|
@ -20,6 +20,7 @@ import { EntityType } from '@shared/models/entity-type.models'; |
|
|
|
import tinycolor from 'tinycolor2'; |
|
|
|
|
|
|
|
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 MarkerImageFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string; |
|
|
|
@ -229,7 +230,6 @@ export const defaultSettings: any = { |
|
|
|
strokeWeight: 2, |
|
|
|
strokeOpacity: 1.0, |
|
|
|
initCallback: () => { }, |
|
|
|
defaultZoomLevel: 8, |
|
|
|
disableScrollZooming: false, |
|
|
|
minZoomLevel: 16, |
|
|
|
credentials: '', |
|
|
|
|
|
|
|
@ -17,7 +17,7 @@ |
|
|
|
|
|
|
|
import L from 'leaflet'; |
|
|
|
import LeafletMap from '../leaflet-map'; |
|
|
|
import { UnitedMapSettings } from '../map-models'; |
|
|
|
import { DEFAULT_ZOOM_LEVEL, UnitedMapSettings } from '../map-models'; |
|
|
|
import 'leaflet.gridlayer.googlemutant'; |
|
|
|
import { ResourcesService } from '@core/services/resources.service'; |
|
|
|
import { WidgetContext } from '@home/models/widget-component.models'; |
|
|
|
@ -39,7 +39,7 @@ export class GoogleMap extends LeafletMap { |
|
|
|
const map = L.map($container, { |
|
|
|
attributionControl: false, |
|
|
|
editable: !!options.editablePolygon |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL); |
|
|
|
(L.gridLayer as any).googleMutant({ |
|
|
|
type: options?.gmDefaultMapType || 'roadmap' |
|
|
|
}).addTo(map); |
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ |
|
|
|
|
|
|
|
import L from 'leaflet'; |
|
|
|
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'; |
|
|
|
|
|
|
|
export class HEREMap extends LeafletMap { |
|
|
|
@ -24,7 +24,7 @@ export class HEREMap extends LeafletMap { |
|
|
|
super(ctx, $container, options); |
|
|
|
const map = L.map($container, { |
|
|
|
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); |
|
|
|
tileLayer.addTo(map); |
|
|
|
super.initSettings(options); |
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ |
|
|
|
|
|
|
|
import L from 'leaflet'; |
|
|
|
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'; |
|
|
|
|
|
|
|
export class OpenStreetMap extends LeafletMap { |
|
|
|
@ -24,7 +24,7 @@ export class OpenStreetMap extends LeafletMap { |
|
|
|
super(ctx, $container, options); |
|
|
|
const map = L.map($container, { |
|
|
|
editable: !!options.editablePolygon |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL); |
|
|
|
let tileLayer; |
|
|
|
if (options.useCustomProvider) { |
|
|
|
tileLayer = L.tileLayer(options.customProviderTileUrl); |
|
|
|
|
|
|
|
@ -17,7 +17,7 @@ |
|
|
|
|
|
|
|
import L from 'leaflet'; |
|
|
|
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'; |
|
|
|
|
|
|
|
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 map = L.map($container, { |
|
|
|
editable: !!options.editablePolygon |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); |
|
|
|
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel || DEFAULT_ZOOM_LEVEL); |
|
|
|
const txLayer = L.tileLayer(txUrl, { |
|
|
|
subdomains: '0123', |
|
|
|
tms: true, |
|
|
|
|