I’m building an Android app that uses the Google Maps api and markers that update position based on a json file grabbed from a server. So, in a controller, I do this:
var bargeFile = 'https://press-street.org/ybh/barge.json';
var bargeMarker = new google.maps.Marker();
$scope.generateBargeMarker = function() {
$http.get(bargeFile, {cache: false}).success( function(data) {
var gps = data["gps"];
bargeMarker.setPosition(new google.maps.LatLng(gps[0], gps[1]));
bargeMarker.setMap(map);
});
};
$scope.generateBargeMarker();
$interval($scope.generateBargeMarker, 6000);
The marker shows up, and the get is definitely succeeding every time, but it must be saving the first value and continuing to use that. The only way to reset it and have it read the new value (after I change values in the file on the server), is to clear the app data in app settings. Also, every time I switch to another view, then back to the map, the total app data increases by some 0.02 mb, which I infer is the files being grabbed, saved, and then not used.
How can I resolve this to have the $http.get call actually use the requested file each time, by I guess having it overwrite the existing saved version or something, or not saving it at all?