How to fix Uncaught InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lat: not a number?

Uncaught InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lat: not a number

Means you are not passing numbers into the google.maps.LatLng constructor. Per your comment:

/*Information from chromium debugger
trader: Object
    geo: Object
        lat: "49.014821"
        lon: "10.985072"

*/

trader.geo.lat and trader.geo.lon are strings, not numbers. Use parseFloat to convert them to numbers:

var myLatlng = new google.maps.LatLng(parseFloat(trader.geo.lat),parseFloat(trader.geo.lon));

Leave a Comment