1
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 complaint that will appear on the map. However, if the user, at another time, wants to make another complaint, the new information must appear. So I need to delete old information to display 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;
})
Fine, but what should I check on that data? I have to erase their data after the display?
– GustavoSevero
According to your question - if the user, at another time, wants to make another complaint, the new information must appear - I would say that your data source should popular these properties (diaDenun, time, type and des) with the new values. This will depend on how the application is implemented.
– OnoSendai
I must set these variables to null after the map is displayed with this information?
– GustavoSevero
This information comes from a form, which the user fills in.
– GustavoSevero
You can monitor the user’s changes, and change the property
content
ofinfowindow
to display the new values.– OnoSendai
Putzzz, but how do I do it?
– GustavoSevero
I would suggest creating a new question containing both the code of the form used by the view user containing this map, since the answer would slip somewhat from the scope of this question.
– OnoSendai
Man, I think you know how to do what you suggested, you wouldn’t have to open up another topic to explain it. Or I give you my email for this: [email protected]. Thanks, right now.
– GustavoSevero