Hello guys,
How can I get two markers on native google maps?
In my project, I need one dynamic marker and one fixed marker.
This is how I’m adding my first marker which is getting its latitude and longitude from a data provider sending the numbers in “place” data object.
addMarker() {
this.map.addMarker({
title: 'My Marker',
icon: 'blue',
animation: 'DROP',
position: {
lat: this.place.lat,
lng: this.place.lng
}
})
.then(marker => {
marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(() => {
alert('Marker Clicked');
});
});
}
I tried to add another marker with fixed longitude and latitude but it doesn’t really work. Google maps shows only one marker added later.
addMarker2() {
this.map.addMarker({
title: 'My Marker',
icon: 'blue',
animation: 'DROP',
position: {
lat: -33,
lng: 773231
}
})
.then(marker => {
marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(() => {
alert('Marker Clicked');
});
});
}
and how can I show route between the two markers?
Thanks in advance,