Browse Source

add bounds padding

pull/2542/head
Artem Halushko 6 years ago
parent
commit
c79b32e769
  1. 8
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 1
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  4. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/polygon.ts
  5. 5
      ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts

8
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -210,8 +210,8 @@ export default abstract class LeafletMap {
private createMarker(key, data: FormattedData, dataSources: FormattedData[], settings: MarkerSettings, setFocus = true) {
this.ready$.subscribe(() => {
const newMarker = new Marker(this.map, this.convertPosition(data), settings, data, dataSources, () => { }, this.dragMarker);
if (setFocus)
this.map.fitBounds(this.bounds.extend(newMarker.leafletMarker.getLatLng()));
if (setFocus && settings.fitMapBounds)
this.map.fitBounds(this.bounds.extend(newMarker.leafletMarker.getLatLng()).pad(0.2));
this.markers.set(key, newMarker);
});
}
@ -245,10 +245,10 @@ export default abstract class LeafletMap {
if (data.length) {
const dataSource = polyData.map(arr => arr[0]);
if (this.poly) {
this.updatePolyline(data, dataSource, this.options);
this.updatePolyline(data, polyData, this.options);
}
else {
this.createPolyline(data, dataSource, this.options);
this.createPolyline(data, polyData, this.options);
}
}
})

1
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts

@ -70,6 +70,7 @@ export type MarkerSettings = {
markerImages?: string[];
useMarkerImage: boolean;
markerImageSize: number;
fitMapBounds: boolean;
markerImage: {
length: number
}

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts

@ -166,6 +166,8 @@ export class MapWidgetController implements MapWidgetInterface {
}
update() {
console.log(parseArray(this.data));
if (this.drawRoutes)
this.map.updatePolylines(parseArray(this.data));
if (this.settings.showPolygon) {

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/polygon.ts

@ -46,9 +46,7 @@ export class Polygon {
}
updatePolygonColor(settings) {
console.log('Polygon -> updatePolygonColor -> settings', settings)
const style: L.PathOptions = {
fill: true,
fillColor: settings.color,
color: settings.color,

5
ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts

@ -34,6 +34,7 @@ export class Polyline {
this.leafletPoly = L.polyline(locations,
this.getPolyStyle(settings)
).addTo(this.map);
if (settings.usePolylineDecorator) {
this.polylineDecorator = L.polylineDecorator(this.leafletPoly, this.getDecoratorSettings(settings)).addTo(this.map);
}
@ -62,12 +63,16 @@ export class Polyline {
updatePolyline(settings, data, dataSources) {
this.leafletPoly.setStyle(this.getPolyStyle(settings));
console.log( this.getPolyStyle(settings));
// this.setPolylineLatLngs(data);
if(this.polylineDecorator)
this.polylineDecorator.setPaths(this.leafletPoly);
}
getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
console.log(this.data,this.dataSources, this.dataSources[this.data[0]?.dsIndex], this.data[0]?.dsIndex);
return {
color: settings.useColorFunction ?
safeExecute(settings.colorFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.color,

Loading…
Cancel
Save