googlemaps showing previous input

This forum contains topics that were moved from Get Satisfaction
David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

googlemaps showing previous input

Post by David wyatt »

Hi Sergiy, thank you for your help. If anyone else is struggling hope this helps

after using this tutorial
https://devcenter.appery.io/tutorials/jqm/building-a-mobile-app-with-google-map-and-geolocation/

Added javascript file with

var aofMarkers=[];

function RemoveMarkersfromMapp() {
var i;
for (i=0; i< aofMarkers.length; i++){
aofMarkers.setMap (null);
}
aofMarkers = [1];
}

then on success of convert_address javascript add aofMarkers.push(marker); line

var markerLatLng = new google.maps.LatLng(localStorage.getItem('markerLat'), localStorage.getItem('markerLng'));

var marker = new google.maps.Marker({
position: markerLatLng,
map: map,
title: data.results[0].address_components[0].long_name,
animation: google.maps.Animation.DROP
});

aofMarkers.push(marker); ///////////// added this line
bounds.extend(markerLatLng);
map.fitBounds(bounds);

then call the RemoveMarkersfromMapp function
RemoveMarkersfromMapp();

to clear markers, i fund the easiest way to do it on a button command

Post Reply