I have created a map in my Ionic project using Maps API v3 and ngCordova to get my current location and with the following code:
var options = {timeout: 10000, enablehighAccuracy: false};
$cordovaGeolocation.getCurrentPosition(options)
.then(function (position) {
var myLat = position.coords.latitude;
var myLong = position.coords.longitude;
console.log(myLat, myLong);
var center = new google.maps.LatLng(myLat, myLong);
var mapOptions = {
center: center,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
mapTypeControl: false,
zoomControl: false
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
}, function (err) {
console.log(err);
});
I would like to create a marker on this map that will stay centered as the map is panned (similar to Hailo, Uber and others) so that the user can define a specific location simply by moving the map. I cannot find anything in the Maps API docs for this or any tutorials/hints.
Can anyone suggest a simple way to do this? Also, am I right in thinking that when the user moves the map, the new coordinates of the centre of the map (where the marker is located) can be retrieved?