Hi Yurii,
Thank you, this helped massively.
I have another question regarding directions.
the JS is:
prevar directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var bounds = new google.maps.LatLngBounds();
function initialize() {
console.log('Initializing...');
Code: Select all
map = Apperyio("google_map").gmap;
if (!map)
{
setDelay();
}
else
{
directionsDisplay = new google.maps.DirectionsRenderer();
}
}
function displayDirections(sourceAddress, destinationAddress, map) {
var request = {
origin: sourceAddress,
destination: destinationAddress,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}
function setDelay()
{
setTimeout(initialize, 50);
}/pre
and the js on button click is:
prevar sourceAddress = Apperyio("from").val();
var destinationAddress = Apperyio("to").val();
displayDirections(sourceAddress, destinationAddress, map);/pre
the source address and destination address I have is saved in local storage.
GeoLat, GeoLng and DestLat, DestLng.
so I changed the code to this:
prevar sourceAddress = (localStorage.getItem('GeoLat'), localStorage.getItem('GeoLng'));
var destinationAddress = (localStorage.getItem('DestLat'), localStorage.getItem('DestLng'));
displayDirections(sourceAddress, destinationAddress, map);/pre
But this didnt work.
How can I fix this?
Cheers,
Joe