Ionic-native-google-maps: Marker anchor doesn't work

Created on 5 Sep 2018  路  11Comments  路  Source: ionic-team/ionic-native-google-maps

I'm submitting a ... (check one with "x")

  • [x] any problem or bug report

If you choose 'problem or bug report', please select OS: (check one with "x")

  • [x] Android

cordova information: (run $> cordova plugin list)

cordova-plugin-googlemaps 2.4.2-beta-20180901-2335 "cordova-plugin-googlemaps"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)
"@angular/core": "~6.1.6",
"@ionic-native/core": "5.0.0-beta.15",
"@ionic-native/google-maps": "^5.0.0-beta.15",

Current behavior:
The anchor property on Marker doesn't work but when we put it on the MarkerIcon it's working.

**There is already a Pull Request for that.

Most helpful comment

@fatalcaron Thak you!. I was having the same issue and your code helped me to solving it. The problem continues in the version 5.0.0-beta.25

All 11 comments

[x, y]

This example doesn't work:

const icon: MarkerIcon = {
  url: 'assets/icon/geolocation_marker.png',
  size: {
    width: 22,
    height: 22
  }
};

this.locationMarker = map.addMarkerSync({
  position: { lat: 45, lng: -71},
  icon: icon,
  anchor: [11, 11]
});

But this example work:

const icon: MarkerIcon = {
  url: 'assets/icon/geolocation_marker.png',
  size: {
    width: 22,
    height: 22
  },
  anchor: {
    x: 11,
    y: 11
  }
};

this.locationMarker = map.addMarkerSync({
  position: { lat: 45, lng: -71},
  icon: icon
});

Why do you need to specify twice?

I edit my comment above

Use the work code.

Yes, for sure :)

I was reporting this issue because people need to modify the interface to make it work.
The pull request #40 already pointing in the good direction.

@fatalcaron Thak you!. I was having the same issue and your code helped me to solving it. The problem continues in the version 5.0.0-beta.25

@wf9a5m75 Why the pull request #40 is still not merged?

I just came across this issue as well. Running on iOS, I had to extend the MarkerIcon interface to add an anchor property.

Array instead of object

still wrong at 5.5.0 version:

export interface MarkerIcon {
url?: string;
size?: {
width?: number;
height?: number;
};
}

Was this page helpful?
0 / 5 - 0 ratings