I'm using google maps js in my project.PRoject shows locations by marker in googlemaps.
I can add marker with some butotn but marker needs lat and long values so i put the locations[0].lat,locations[0].lon,
It works fine but not user friendly.
So, what i want to do is make a static marker into the center of the map, when user slides the map , it will still stay in the middle when the user scrolls the map then user clicks the add location button then it adds.
It can also done with add marker in current view center
Current add location code, map and title is global, index comes from document.ready foreach loop
function addLocation(){
var myLatlng = new google.maps.LatLng(allMarkers[0].position.lat()+0.20, allMarkers[0].position.lng()+0.20);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: title,
draggable: true,
index:index
});
marker.addListener('dragend', handleEvent);
marker.addListener("click", () => {
allMarkers[index].isDeleted='1';
allMarkers[index].setMap(null);
});
allMarkers.push(marker);
}