consider this code:
const element = new google.maps.marker.AdvancedMarkerElement();
element.position = new google.maps.LatLng ();
const position2 = element.position;
position2 instanceof google.maps.LatLng
Problem ! last statement ie evaluated to false !
My solution, set a Position class:
I use this class;
class Position {
lat;
lng;
set (latlngObj) {
if (latlngObj instanceof google.maps.LatLng) {
this.lat = latlngObj.lat();
this.lng = latlngObj.lng();
}
else {
this.lat = latlngObj.lat;
this.lng = latlngObj.lng;
}
}
get () {
return newLatLng (this.lat, this.lng);
}
}
New contributor
Jean-Jacques is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2