I understand that ionic native google maps only works on device.
My code looks like these:
private onPlatformReady(): void {
try {
Geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude - resp.coords.longitude
let myPosition = new GoogleMapsLatLng(resp.coords.latitude, resp.coords.longitude);
console.log("My position is", myPosition);
GoogleMap.isAvailable().then(() => {
this.map = new GoogleMap('map_canvas', { target: myPosition, zoom: 14 });
this.map.one(GoogleMapsEvent.MAP_READY).then((data: any) => {
this.map.moveCamera({ target: myPosition, zoom: 14 });
let markerOptions: GoogleMapsMarkerOptions = {
position: myPosition,
title: 'Estas aquí!',
icon: { url : 'img/marker.png' },
animation: GoogleMapsAnimation.BOUNCE
};
this.map.addMarker(markerOptions).then(
(marker: GoogleMapsMarker) => {
marker.showInfoWindow();
}
);
})
});
});
} catch (error) {
alert(error);
}
}