Tom6106181
Posts: 0
Joined: Fri Aug 02, 2013 12:39 pm

Google map directions not updating map

Hi.
I am struggling with my directionsScreen, and to get the map updated with correct destinations. The Panel with discriptions are updated right away, but the map, nothing is happening, it stays put on default address; San Francisco, CA

oh.. and,, I have double and tripple checked the component names :)
Suggestions?

Screen - load - javascript
code
var startLocation = '59.32893000000001, 18.06491';
var endLocation = '52.32893000000001, 18.064910000000054';

var directionsDisplay;
var directionsService = new google.maps.DirectionsService();

var map = Appery("directionsMap").gmap;
var panel = Appery("directionsPanel")[0];

function initDirections() {
directionsDisplay = new google.maps.DirectionsRenderer();
}
function displayDirections(sourceLocation, destinationLocation, map, panel) {
var request = {
origin: sourceLocation,
destination: destinationLocation,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (panel !== null) {
directionsDisplay.setPanel(panel);
}
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert("Directions query unsuccessful. Response status: " + status);
}
});
}

initDirections();
displayDirections(startLocation, endLocation, map, panel);
/code

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Google map directions not updating map

HI Tom,

You can use coderefresh();/code to update Map data.

Tom6106181
Posts: 0
Joined: Fri Aug 02, 2013 12:39 pm

Google map directions not updating map

But where?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Google map directions not updating map

Hello! Most likely map is not initialized when you run your code (if we understand correctly on Load event). Please take a look here https://getsatisfaction.com/apperyio/...

Tom6106181
Posts: 0
Joined: Fri Aug 02, 2013 12:39 pm

Google map directions not updating map

So, I figured it out, Maryna are correct, map not initialized. So, I simply changed from load to page show, and everything working like a charm :p

Return to “Issues”