Skip to content

Commit

Permalink
fixbug: fix angle/iconAnchor in web side
Browse files Browse the repository at this point in the history
  • Loading branch information
liodali committed Dec 31, 2023
1 parent 282828b commit 000bf0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions flutter_osm_web/lib/src/asset/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@
if (iconMarker != "") {
argsIcon["iconUrl"] = "data:image/png;base64," + iconMarker
}
if (anchor != undefined && (anchor.x<=1 && anchor.y<=1)) {
if (anchor != undefined && (anchor.x <= 1 && anchor.y <= 1)) {
var anchorX = anchor.x * iconSize.width
var anchorY = anchor.y * iconSize.height
var anchorY = anchor.y * (iconSize.height - 1)
if(anchor.offset != undefined){
var offsetX = -anchor.offset.x
var offsetY = anchor.offset.y
Expand All @@ -265,6 +265,8 @@
anchorY += (offsetY)
}
argsIcon["iconAnchor"] = [anchorX,anchorY]
}else {
argsIcon["iconAnchor"] = [anchor.x,anchor.y]
}

var args = {
Expand Down Expand Up @@ -320,11 +322,14 @@
x:iconMarker.options.iconAnchor[0],
y:iconMarker.options.iconAnchor[1]
};
console.log(iconAnchor)
console.log("anchor param: "+anchor)
}
if((anchor != undefined && anchor != null) && anchor!=iconAnchor) {
if((anchor != undefined && anchor != null) && anchor != iconAnchor) {
iconAnchor = anchor;
}
mainLayers.get("markers").removeLayer(layer);
console.log(iconAnchor)
addMarker(point,_iconSize,iconMarkerURL,angleMarker,iconAnchor)
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion flutter_osm_web/lib/src/controller/web_osm_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ final class WebOsmController with WebMixin implements IBaseOSMController {
newLocation.toGeoJS(),
icon,
iconSize,
angle != null ? (angle * (180 / pi)) : 0,
angle != null ? (angle * (180 / pi)) : null,
iconAnchor?.toAnchorJS,
);
});
Expand Down

0 comments on commit 000bf0b

Please sign in to comment.