Started edit ad option.
This commit is contained in:
@@ -36,6 +36,9 @@
|
||||
let places;
|
||||
let geocoder;
|
||||
let marker =false; //Initialy no marker on map
|
||||
|
||||
const editingRealEstate = <%- editingRealEstate %>;
|
||||
|
||||
|
||||
function locateMe() {
|
||||
if (navigator.geolocation) {
|
||||
@@ -101,6 +104,13 @@
|
||||
autocomplete.addListener("place_changed", onPlaceChanged);
|
||||
pacSelectFirst(inputElement);
|
||||
addLocateMeButton(map);
|
||||
|
||||
//Move map and marker to already selected position if in editing mode
|
||||
if( editingRealEstate===true) {
|
||||
console.log('Editujem mapu!');
|
||||
setMarkerToLocation(map);
|
||||
}
|
||||
|
||||
//Add event listener to position marker on map
|
||||
google.maps.event.addListener(map, 'click', positionMarker);
|
||||
|
||||
@@ -114,13 +124,31 @@
|
||||
map: map,
|
||||
draggable: true
|
||||
});
|
||||
google.maps.event.addListener(marker, 'dragend', function(event){
|
||||
markerLocation();
|
||||
});
|
||||
//google.maps.event.addListener(marker, 'dragend', function(event){
|
||||
// markerLocation();
|
||||
// });
|
||||
} else{
|
||||
marker.setPosition(clickedLocation);
|
||||
}
|
||||
}
|
||||
function setMarkerToLocation(map) {
|
||||
const ESTATE_COORDINATES = {
|
||||
lat: <%= locationLat %>,
|
||||
lng: <%= locationLong %>
|
||||
};
|
||||
|
||||
marker = new google.maps.Marker({
|
||||
position: ESTATE_COORDINATES,
|
||||
map: map,
|
||||
draggable: true
|
||||
});
|
||||
// google.maps.event.addListener(marker, 'dragend', function(event){
|
||||
// markerLocation();
|
||||
// });
|
||||
//Zooming map to current location
|
||||
map.setCenter(ESTATE_COORDINATES);
|
||||
map.setZoom(13);
|
||||
}
|
||||
|
||||
function addLocateMeButton(map) {
|
||||
var parent = document.createElement("div");
|
||||
|
||||
Reference in New Issue
Block a user