Skip to content

Commit e082fd4

Browse files
committed
v1.2.3
2 parents 00413aa + 678b92c commit e082fd4

File tree

6 files changed

+68
-23
lines changed

6 files changed

+68
-23
lines changed

dist/angular-openlayers-directive.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,9 @@ angular.module('openlayers-directive').directive('olMarker', ["$log", "$q", "olM
773773
coord = coord.map(function(v) {
774774
return parseInt(v, 10);
775775
});
776+
} else {
777+
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
776778
}
777-
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
778779

779780
if (evt.type === 'pointerdown') {
780781
// Get feature under mouse if any
@@ -788,7 +789,11 @@ angular.module('openlayers-directive').directive('olMarker', ["$log", "$q", "olM
788789
return;
789790
}
790791
map.getTarget().style.cursor = 'pointer';
791-
pickOffset = [coord[0] - pickProperties.lon, coord[1] - pickProperties.lat];
792+
if (proj === 'pixel') {
793+
pickOffset = [coord[0] - pickProperties.coord[0], coord[1] - pickProperties.coord[1]];
794+
} else {
795+
pickOffset = [coord[0] - pickProperties.lon, coord[1] - pickProperties.lat];
796+
}
792797
evt.preventDefault();
793798
} else if (pickOffset && pickProperties) {
794799
if (evt.type === 'pointerup') {
@@ -800,8 +805,13 @@ angular.module('openlayers-directive').directive('olMarker', ["$log", "$q", "olM
800805
evt.preventDefault();
801806
scope.$apply(function() {
802807
// Add current delta to marker initial position
803-
pickProperties.lon = coord[0] - pickOffset[0];
804-
pickProperties.lat = coord[1] - pickOffset[1];
808+
if (proj === 'pixel') {
809+
pickProperties.coord[0] = coord[0] - pickOffset[0];
810+
pickProperties.coord[1] = coord[1] - pickOffset[1];
811+
} else {
812+
pickProperties.lon = coord[0] - pickOffset[0];
813+
pickProperties.lat = coord[1] - pickOffset[1];
814+
}
805815
});
806816
}
807817
}
@@ -1000,8 +1010,13 @@ angular.module('openlayers-directive').directive('olMarker', ["$log", "$q", "olM
10001010
marker.set('marker', properties);
10011011
markerLayer.getSource().addFeature(marker);
10021012
} else {
1003-
var requestedPosition = ol.proj.transform([properties.lon, properties.lat], data.projection,
1004-
map.getView().getProjection());
1013+
var requestedPosition;
1014+
if (properties.projection === 'pixel') {
1015+
requestedPosition = properties.coord;
1016+
} else {
1017+
requestedPosition = ol.proj.transform([properties.lon, properties.lat], data.projection,
1018+
map.getView().getProjection());
1019+
}
10051020

10061021
if (!angular.equals(marker.getGeometry().getCoordinates(), requestedPosition)) {
10071022
var geometry = new ol.geom.Point(requestedPosition);

dist/angular-openlayers-directive.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-openlayers-directive.min.no-header.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-openlayers-directive.pre.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,9 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
773773
coord = coord.map(function(v) {
774774
return parseInt(v, 10);
775775
});
776+
} else {
777+
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
776778
}
777-
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
778779

779780
if (evt.type === 'pointerdown') {
780781
// Get feature under mouse if any
@@ -788,7 +789,11 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
788789
return;
789790
}
790791
map.getTarget().style.cursor = 'pointer';
791-
pickOffset = [coord[0] - pickProperties.lon, coord[1] - pickProperties.lat];
792+
if (proj === 'pixel') {
793+
pickOffset = [coord[0] - pickProperties.coord[0], coord[1] - pickProperties.coord[1]];
794+
} else {
795+
pickOffset = [coord[0] - pickProperties.lon, coord[1] - pickProperties.lat];
796+
}
792797
evt.preventDefault();
793798
} else if (pickOffset && pickProperties) {
794799
if (evt.type === 'pointerup') {
@@ -800,8 +805,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
800805
evt.preventDefault();
801806
scope.$apply(function() {
802807
// Add current delta to marker initial position
803-
pickProperties.lon = coord[0] - pickOffset[0];
804-
pickProperties.lat = coord[1] - pickOffset[1];
808+
if (proj === 'pixel') {
809+
pickProperties.coord[0] = coord[0] - pickOffset[0];
810+
pickProperties.coord[1] = coord[1] - pickOffset[1];
811+
} else {
812+
pickProperties.lon = coord[0] - pickOffset[0];
813+
pickProperties.lat = coord[1] - pickOffset[1];
814+
}
805815
});
806816
}
807817
}
@@ -1000,8 +1010,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
10001010
marker.set('marker', properties);
10011011
markerLayer.getSource().addFeature(marker);
10021012
} else {
1003-
var requestedPosition = ol.proj.transform([properties.lon, properties.lat], data.projection,
1004-
map.getView().getProjection());
1013+
var requestedPosition;
1014+
if (properties.projection === 'pixel') {
1015+
requestedPosition = properties.coord;
1016+
} else {
1017+
requestedPosition = ol.proj.transform([properties.lon, properties.lat], data.projection,
1018+
map.getView().getProjection());
1019+
}
10051020

10061021
if (!angular.equals(marker.getGeometry().getCoordinates(), requestedPosition)) {
10071022
var geometry = new ol.geom.Point(requestedPosition);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
6262
},
6363
"main": "dist/angular-openlayers-directive",
64-
"version": "1.2.2"
64+
"version": "1.2.3"
6565
}

src/directives/marker.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
109109
coord = coord.map(function(v) {
110110
return parseInt(v, 10);
111111
});
112+
} else {
113+
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
112114
}
113-
coord = ol.proj.transform(coord, proj, 'EPSG:4326');
114115

115116
if (evt.type === 'pointerdown') {
116117
// Get feature under mouse if any
@@ -124,7 +125,11 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
124125
return;
125126
}
126127
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+
}
128133
evt.preventDefault();
129134
} else if (pickOffset && pickProperties) {
130135
if (evt.type === 'pointerup') {
@@ -136,8 +141,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
136141
evt.preventDefault();
137142
scope.$apply(function() {
138143
// 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+
}
141151
});
142152
}
143153
}
@@ -336,8 +346,13 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q,
336346
marker.set('marker', properties);
337347
markerLayer.getSource().addFeature(marker);
338348
} 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+
}
341356

342357
if (!angular.equals(marker.getGeometry().getCoordinates(), requestedPosition)) {
343358
var geometry = new ol.geom.Point(requestedPosition);

0 commit comments

Comments
 (0)