@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models' ;
import { UnitedMapSettings } from '../map-models' ;
import { Observable } from 'rxjs' ;
import { Observable } from 'rxjs' ;
import { map , filter , switchMap } from 'rxjs/operators' ;
import { map , filter , switchMap } from 'rxjs/operators' ;
import { aspectCache , parseFunction } from '@home/components/widget/lib/maps/maps-utils' ;
import { aspectCache , calculateNewPointCoordinate , parseFunction } from '@home/components/widget/lib/maps/maps-utils' ;
const maxZoom = 4 ; // ?
const maxZoom = 4 ; // ?
@ -79,9 +79,10 @@ export class ImageMap extends LeafletMap {
if ( lastCenterPos ) {
if ( lastCenterPos ) {
lastCenterPos . x *= w ;
lastCenterPos . x *= w ;
lastCenterPos . y *= h ;
lastCenterPos . y *= h ;
/ * t h i s . c t x . $ s c o p e . $ i n j e c t o r . g e t ( ' $ m d U t i l ' ) . n e x t T i c k ( ( ) = > {
const center = this . pointToLatLng ( lastCenterPos . x , lastCenterPos . y ) ;
this . map . panTo ( center , { animate : false } ) ;
setTimeout ( ( ) = > {
} ) ; * /
this . map . panTo ( center , { animate : false } ) ;
} , 0 ) ;
}
}
}
}
@ -97,7 +98,7 @@ export class ImageMap extends LeafletMap {
width *= maxZoom ;
width *= maxZoom ;
const prevWidth = this . width ;
const prevWidth = this . width ;
const prevHeight = this . height ;
const prevHeight = this . height ;
if ( this . width !== width ) {
if ( this . width !== width || updateImage ) {
this . width = width ;
this . width = width ;
this . height = width / this . aspect ;
this . height = width / this . aspect ;
if ( ! this . map ) {
if ( ! this . map ) {
@ -108,6 +109,7 @@ export class ImageMap extends LeafletMap {
lastCenterPos . y /= prevHeight ;
lastCenterPos . y /= prevHeight ;
this . updateBounds ( updateImage , lastCenterPos ) ;
this . updateBounds ( updateImage , lastCenterPos ) ;
this . map . invalidateSize ( true ) ;
this . map . invalidateSize ( true ) ;
// TODO: need add update marker position
}
}
}
}
}
}
@ -133,7 +135,7 @@ export class ImageMap extends LeafletMap {
convertPosition ( expression ) : L . LatLng {
convertPosition ( expression ) : L . LatLng {
if ( isNaN ( expression [ this . options . xPosKeyName ] ) || isNaN ( expression [ this . options . yPosKeyName ] ) ) return null ;
if ( isNaN ( expression [ this . options . xPosKeyName ] ) || isNaN ( expression [ this . options . yPosKeyName ] ) ) return null ;
Object . assign ( expression , this . posFunction ( expression [ this . options . xPosKeyName ] , expression [ this . options . yPosKeyName ] ) )
Object . assign ( expression , this . posFunction ( expression [ this . options . xPosKeyName ] , expression [ this . options . yPosKeyName ] ) ) ;
return this . pointToLatLng (
return this . pointToLatLng (
expression . x * this . width ,
expression . x * this . width ,
expression . y * this . height ) ;
expression . y * this . height ) ;
@ -148,9 +150,10 @@ export class ImageMap extends LeafletMap {
}
}
convertToCustomFormat ( position : L.LatLng ) : object {
convertToCustomFormat ( position : L.LatLng ) : object {
const point = this . latLngToPoint ( position ) ;
return {
return {
[ this . options . xPosKeyName ] : ( position . lng + 180 ) / 360 ,
[ this . options . xPosKeyName ] : calculateNewPointCoordinate ( point . x , this . width ) ,
[ this . options . yPosKeyName ] : ( position . lat + 180 ) / 360
[ this . options . yPosKeyName ] : calculateNewPointCoordinate ( point . y , this . height )
}
}
}
}
}
}