@@ -109,8 +109,9 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
109
109
coord = coord . map ( function ( v ) {
110
110
return parseInt ( v , 10 ) ;
111
111
} ) ;
112
+ } else {
113
+ coord = ol . proj . transform ( coord , proj , 'EPSG:4326' ) ;
112
114
}
113
- coord = ol . proj . transform ( coord , proj , 'EPSG:4326' ) ;
114
115
115
116
if ( evt . type === 'pointerdown' ) {
116
117
// Get feature under mouse if any
@@ -124,7 +125,11 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
124
125
return ;
125
126
}
126
127
map . getTarget ( ) . style . cursor = 'pointer' ;
127
- pickOffset = [ coord [ 0 ] - pickProperties . lon , coord [ 1 ] - pickProperties . lat ] ;
128
+ if ( proj === 'pixel' ) {
129
+ pickOffset = [ coord [ 0 ] - pickProperties . coord [ 0 ] , coord [ 1 ] - pickProperties . coord [ 1 ] ] ;
130
+ } else {
131
+ pickOffset = [ coord [ 0 ] - pickProperties . lon , coord [ 1 ] - pickProperties . lat ] ;
132
+ }
128
133
evt . preventDefault ( ) ;
129
134
} else if ( pickOffset && pickProperties ) {
130
135
if ( evt . type === 'pointerup' ) {
@@ -136,8 +141,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
136
141
evt . preventDefault ( ) ;
137
142
scope . $apply ( function ( ) {
138
143
// Add current delta to marker initial position
139
- pickProperties . lon = coord [ 0 ] - pickOffset [ 0 ] ;
140
- pickProperties . lat = coord [ 1 ] - pickOffset [ 1 ] ;
144
+ if ( proj === 'pixel' ) {
145
+ pickProperties . coord [ 0 ] = coord [ 0 ] - pickOffset [ 0 ] ;
146
+ pickProperties . coord [ 1 ] = coord [ 1 ] - pickOffset [ 1 ] ;
147
+ } else {
148
+ pickProperties . lon = coord [ 0 ] - pickOffset [ 0 ] ;
149
+ pickProperties . lat = coord [ 1 ] - pickOffset [ 1 ] ;
150
+ }
141
151
} ) ;
142
152
}
143
153
}
@@ -336,8 +346,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
336
346
marker . set ( 'marker' , properties ) ;
337
347
markerLayer . getSource ( ) . addFeature ( marker ) ;
338
348
} else {
339
- var requestedPosition = ol . proj . transform ( [ properties . lon , properties . lat ] , data . projection ,
340
- map . getView ( ) . getProjection ( ) ) ;
349
+ var requestedPosition ;
350
+ if ( properties . projection === 'pixel' ) {
351
+ requestedPosition = properties . coord ;
352
+ } else {
353
+ requestedPosition = ol . proj . transform ( [ properties . lon , properties . lat ] , data . projection ,
354
+ map . getView ( ) . getProjection ( ) ) ;
355
+ }
341
356
342
357
if ( ! angular . equals ( marker . getGeometry ( ) . getCoordinates ( ) , requestedPosition ) ) {
343
358
var geometry = new ol . geom . Point ( requestedPosition ) ;
0 commit comments