I have an ionic app that makes use of google maps. In this map I display information that the user provides. For example: The user wants to make a report that will appear on the map. However, if the user, at another time, wants to make another complaint, the new information should appear. So I need to delete the old information to display the new information. How can I do this?
My code in angular:
.controller('MapaResCtrl', function($scope, $rootScope) {
$rootScope.diaDenun;
$rootScope.hora;
$rootScope.tipo;
$rootScope.des;
$rootScope.coordenadas;
var mapOptions = {
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
navigator.geolocation.getCurrentPosition(function(pos) {
map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
$rootScope.myLocation = new google.maps.Marker({
position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
map: map,
title: "My Location",
//animation:google.maps.Animation.BOUNCE
});
var infowindow = new google.maps.InfoWindow({
content: "Dia da denúncia "+$rootScope.diaDenun+" Hora: "+$rootScope.hora+" Tipo: "+$rootScope.tipo+" Descrição: "+$rootScope.des
});
infowindow.open(map,$rootScope.myLocation);
});
$scope.map = map;
})