I have the following JavaScript code that displays the current location of a user in a map every 15 seconds. My problem is that once the browser reaches certain amount of refreshes it stops working. This happens quicker if a mobile browser is being used. I would like to know if there is a way for me to clear the browser's memory so that the application continues to work. Thanks
<!DOCTYPE html> <html> <head> <title>Map</title> <link rel="stylesheet" href="layout.css"/> <!--<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"> </script> <script type="text/javascript"> //Jquery function that waits until the html is fully loaded to then execute pending JavaScript code. $(document).ready(function () { setInterval( function initialize() { navigator.geolocation.getCurrentPosition( function geoPosition(location) { console.log(location); //Assigns coordinates to the variable. var currentLocation = new google.maps.LatLng(location.coords.latitude, location.coords.longitude); //Displays the map on the canvas. var mapOptions = { panControl: false, zoomControl: false, mapTypeControl: false, scaleControl: false, streetViewControl: false, overviewMapControl: false, scrollwheel: false, navigationControl: false, mapTypeControl: false, draggable: false, //center: new google.maps.LatLng(25.753981, -80.375633), center: currentLocation,//Displays the location zoom: 15,//How far or close mapTypeId: google.maps.MapTypeId.TERRAIN//Type of map }; //Objects of this class define a single map on a page. var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); //Identifies user's location and tdisplays pin on a map. var marker = new google.maps.Marker({ position: currentLocation,//Map location displayed //position: new google.maps.LatLng(25.753981, -80.375633), map: map //icon : 'map_icons/person.png'//Set a custom icon }); }) }, 15000); }); </script>