Spark,
Here's the code I use to get the map - and then to add marker(s) to it....
Much like the comment above - I get my map here (so adjust your code please)
var map = Appery("google_map").options.mapElement.gmap('get', 'map'); // where 'google_map' is what you called your map in the designer ....
// Then if you're in the page show event.... I'd add code like this -- you might want to first --- set the center of your map to the lat/long of the marker perhaps...
// first things first - wait for the map.... -- please read this :
http://www.w3schools.com/jsref/met_wi...
// code to wait...in your show event...
var map = Appery("google_map").options.mapElement.gmap('get', 'map'); // where 'google_map' is what you called your map in the designer ....
do {
setTimeout( fdropMarker( map ), 500);
} while (!map);
// this will cause you to wait 500 milliseconds (.5 seconds) and then execute the function called fdropMarker( ) ...
inside the show event or in a separate JS script (my preference):
function fdropMarker( oMap ) {
// get lat and long - make sure they are numerics when retrieved.....
var nlatiTude = Number( localStorage.getItem('markerLat') );
var nlongtiTude = Number(localStorage.getItem('markerLng') ) ;
var oposition;
// if the map exists --- continue - otherwise just return until the next call when it does...
if ( oMap ){
// set the center of the map to the long and lat...
oposition = new google.maps.LatLng( nlatiTude, lnlongtiTude);
oMap.setCenter( oposition ) ;
// create the marker ...
var marker = new google.maps.Marker({
position: oposition,
map: oMap
});
// note that here - since you've called another external api - you may need to create a wait here - while the API calls process..... but - likely not....
} // end the if statement on if map exists
return ;
}