B4J Question Google Maps Waypoint Anchor Change


Active Member
Licensed User
Any marker added with the jGoogleMaps library displays the marker with the bitmap anchored at the centre of the bottom margin. Is it possible to expose the properties of the marker such that the bitmap is centred over the co-ordinate rather than above it?

Rather like the Android library GoogleMapExtras MarkerObject.Anchor(xOffset,yOffset) provides? Can this be exposed with a JavaObject?

Andrew (Digitwell)

Well-Known Member
Licensed User
try this from @warwound

There is a Markerextras class which will allow you to set the anchor for the marker.

    Private mrke As MarkerExtras

xoff and yoff are between 0 and 1, so


set the anchor to the middle of the marker.
Upvote 0


B4X founder
Staff member
Licensed User

Dim m As Marker = gmap.AddMarker(30, 30, "test")
Dim jo As JavaObject = m
Log(jo.GetFieldJO("jsObject").RunMethod("eval", Array($"
 var image = {
    url: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
    size: new google.maps.Size(20, 32),
    origin: new google.maps.Point(0, 0),
    anchor: new google.maps.Point(0, 32)

Upvote 0


Active Member
Licensed User
I have learnt several lessons in dealing with Google Maps Marker Objects.......

1. The default marker anchor is not at all intuitive. If you are hoping to add a polyline depicting a route, having the line pass through the bottom-centre of the marker is not visually pleasing. The only exception to this is perhaps a triangle graphic with the apex pointing downwards.

2. If you centre the anchor make sure your marker graphic has a sufficiently clear area at the centre, or use transparency, so that you can actually see the anchor position when you drag it.

3. For the uninitiated.... Java Object code is difficult to write and almost impossible to debug if it does not work because there is little feedback. For this reason I have put a known working example into a class module and call it from there supplying suitable constants for various alignments. Acknowledgements to @Erel and @Andrew (Digitwell) for some snippets of the code.


  • jMarker Example.zip
    10.2 KB · Views: 95
  • jCustomMarker.bas
    1.5 KB · Views: 81
Upvote 0