Guys,
I’ve tried to get new position of dragged marker but i failed. could you please help me.I have error in fallowing code.
addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter(),
draggable: true
});
marker.addEventListener(plugin.google.maps.event.MARKER_DRAG_END, function(marker) {
marker.getPosition(function(latLng) {
marker.setTitle(latLng.toUrlValue());
marker.showInfoWindow();
});
});
}
I also tried this code but it fails too:
addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter(),
draggable: true
});
marker.addEventListener(GoogleMapsEvent.MARKER_DRAG_END).subscribe(
data => {
marker.getPosition()
.then((LatLng) => {
alert('GoogleMapsEvent.MARKER_DRAG_END Lat ~ '+LatLng.lat() + ' And Long ~ '+LatLng.lng())
});
});
}
Packages that have installed:
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/storage": "1.1.7",
"@types/google-maps": "^3.2.0",
"angular2-google-maps": "^0.17.0",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.16",
"ionicons": "3.0.0",
"promise": "^7.1.1",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
},
"devDependencies": {
"@ionic/app-scripts": "0.0.47",
"@types/google-maps": "3.2.0",
"typescript": "2.0.9"
},
Duds, I need help. please.
rsa
January 16, 2017, 7:53pm
4
Do you checked this post?
Plugin is not defined
Dear friends anyone have Idea? Please this become a critical part of my project and unfortunately I’m my time going to finish.
Pleasr.
Yes i installed ionic-native 1.2.4 but nothing still any code for drag event shows error.
hzhong
February 23, 2017, 10:57pm
7
Hi Parsian how was your project going? My project has encountered the same issue right now. I have searched a lot of forums for solutions but none of those worked so far. I can getcurrentposition() using googlemap plugins but not the dragged marker. Please let me know if you have found a solution or not, or even if you figured out a way to work around it. Thank you!
Hello guys, have you found a solution yet? I have the same problem over here.
something like this:
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter(),
draggable: true
, icon: image
});
this.lastLatLng(marker)
lastLatLng(marker){
google.maps.event.addListener(marker, 'dragend', () =>{
this.LastLat= marker.position.lat();
this.LastLng= marker.position.lng();
this.Getaddress(this.LastLat,this.LastLng, marker,source);
});
}
4 Likes
this.Getaddress(this.LastLat,this.LastLng, marker,source);
can you explain this code?
I have multiple marker this function return the address of dragged marker. this is not expert code I am not expert one.