@@ -259,6 +259,15 @@ private Marker createMarker(Map<String, Object> optionsMap, String customId) {
259259 boolean draggable = CollectionUtil .getBool ("draggable" , optionsMap , false );
260260 boolean flat = CollectionUtil .getBool ("flat" , optionsMap , false );
261261 boolean visible = CollectionUtil .getBool ("visible" , optionsMap , true );
262+ float anchorU = 0.5f ;
263+ float anchorV = 1.0f ;
264+ if (optionsMap .containsKey ("anchor" )) {
265+ Map <String , Object > anchor = (Map <String , Object >) optionsMap .get ("anchor" );
266+ if (anchor != null ) {
267+ anchorU = Double .valueOf (CollectionUtil .getDouble ("u" , anchor , 0.5 )).floatValue ();
268+ anchorV = Double .valueOf (CollectionUtil .getDouble ("v" , anchor , 1.0 )).floatValue ();
269+ }
270+ }
262271
263272 MarkerOptions options = new MarkerOptions ();
264273 if (imagePath != null && !imagePath .isEmpty ()) {
@@ -284,6 +293,7 @@ private Marker createMarker(Map<String, Object> optionsMap, String customId) {
284293 options .flat (flat );
285294 options .alpha (alpha );
286295 options .rotation (rotation );
296+ options .anchor (anchorU , anchorV );
287297 options .draggable (draggable );
288298 options .visible (visible );
289299
@@ -307,6 +317,15 @@ private void updateMarker(Marker marker, Map<String, Object> optionsMap) {
307317 boolean draggable = CollectionUtil .getBool ("draggable" , optionsMap , false );
308318 boolean flat = CollectionUtil .getBool ("flat" , optionsMap , false );
309319 boolean visible = CollectionUtil .getBool ("visible" , optionsMap , true );
320+ float anchorU = 0.5f ;
321+ float anchorV = 1.0f ;
322+ if (optionsMap .containsKey ("anchor" )) {
323+ Map <String , Object > anchor = (Map <String , Object >) optionsMap .get ("anchor" );
324+ if (anchor != null ) {
325+ anchorU = Double .valueOf (CollectionUtil .getDouble ("u" , anchor , 0.5 )).floatValue ();
326+ anchorV = Double .valueOf (CollectionUtil .getDouble ("v" , anchor , 1.0 )).floatValue ();
327+ }
328+ }
310329
311330 if (imagePath != null && !imagePath .isEmpty ()) {
312331 try {
@@ -331,6 +350,7 @@ private void updateMarker(Marker marker, Map<String, Object> optionsMap) {
331350 marker .setFlat (flat );
332351 marker .setAlpha (alpha );
333352 marker .setRotation (rotation );
353+ marker .setAnchor (anchorU , anchorV );
334354 marker .setDraggable (draggable );
335355 marker .setVisible (visible );
336356 }
0 commit comments