Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back iconOffset support for the API #4869

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/dist/apihelp/data.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id point title description icon
1 553000,216300 Information Office de l'information<br />Tél: 032 000 00 00<br>Email: <a href="mailto:info@example.com">info@example.com</a><br />Internet: <a href="http://fr.wikipedia.org/wiki/La_Chaux-de-Fonds" target=new>Cliquer ici</a> http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker.png
2 554250,215600 Ma première station Diesel pas cher http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png
3 552556,215864 Mon parking C'est celui-là le meilleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png
4 554489,217126 Mon parking Ce parking est<br/>le meillleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png
5 554089,217326 Ma deuxième station Sans-plomb pas cher. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png
id point title description icon iconSize iconOffset
1 553000,216300 Information Office de l'information<br />Tél: 032 000 00 00<br>Email: <a href="mailto:info@example.com">info@example.com</a><br />Internet: <a href="http://fr.wikipedia.org/wiki/La_Chaux-de-Fonds" target=new>Cliquer ici</a> http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker.png 21,25 -10.5,-25
2 554250,215600 Ma première station Diesel pas cher http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png 21,25 -10.5,-25
3 552556,215864 Mon parking C'est celui-là le meilleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png 21,25 -10.5,-25
4 554489,217126 Mon parking Ce parking est<br/>le meillleur. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-gold.png 21,25 -10.5,-25
5 554089,217326 Ma deuxième station Sans-plomb pas cher. http://dev.openlayers.org/releases/OpenLayers-2.13.1/img/marker-blue.png 21,25 -10.5,-25
10 changes: 9 additions & 1 deletion api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,17 @@ class Map {
});
marker.setProperties(filterByKeys(values, attr));
marker.setId(values.id);
let anchor;
if (values.iconOffset) {
// flip the sign of the value to be compatible with the old api.
anchor = values.iconOffset.split(',').map(parseFloat).map(val => val * Math.sign(val));
}
marker.setStyle(new Style({
image: new Icon({
src: values.icon
src: values.icon,
anchorXUnits: 'pixels',
anchorYUnits: 'pixels',
anchor: anchor
})
}));
this.vectorSource_.addFeature(marker);
Expand Down