Page 1 of 1

Google map directions not updating map

Posted: Thu Feb 20, 2014 1:49 pm
by Tom6106181

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


Google map directions not updating map

Posted: Thu Feb 20, 2014 2:13 pm
by Kateryna Grynko

HI Tom,

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


Google map directions not updating map

Posted: Thu Feb 20, 2014 2:21 pm
by Tom6106181

But where?


Google map directions not updating map

Posted: Thu Feb 20, 2014 5:06 pm
by Maryna Brodina

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/...


Google map directions not updating map

Posted: Thu Feb 20, 2014 7:44 pm
by Tom6106181

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