0

When using ng-map, I get this error after I click a custom button that I've implemented to get the user's current location:

InvalidValueError: setCenter: not a LatLng or LatLngLiteral: not an Object

I'm not doing 'setCenter' explicitly, and the error only occurs after I do a check on the user's current location using:

navigator.geolocation.getCurrentPosition

I have other custom buttons, and clicking them doesn't cause the error - the issue is specifically related to the 'current location' button somehow. What could be causing this? I know that this can be called if a null or incorrectly formed value is passed for lat and long, but I'm not doing anything to explicitly center the map on a specified lat and long.

Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206

1 Answers1

0

I discovered that the problem was with the ng-map custom-marker I'm using for showing the current position. When this was displayed (after I set my mapsCtrl.showCurrentLocation property to true), it was trying to center because it had a 'centered' attribute set to 'true':

custom-marker position="current-location" centered="true" ng-if="mapsCtrl.showCurrentLocation">

I don't know why it couldn't find a valid value current center (I tried setting a LatLng value for the 'center' property on my ng-map), however removing this attribute and then manually setting the center of my map in code fixes the issue.

Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206