How to delete data from google maps

Asked

Viewed 115 times

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;

})

Print how information appears on the map: inserir a descrição da imagem aqui

2 answers

2


Your Google Maps interface implementation does not require any changes.

Values are being read from variables created in $rootScope:

var infowindow = new google.maps.InfoWindow({
            content: 
            "Dia da denúncia "+ $rootScope.diaDenun + 
            " Hora: " + $rootScope.hora +
            " Tipo: " + $rootScope.tipo + 
            " Descrição: "+$rootScope.des
      });

If you want to display other values, check the part of your code that populates the properties diaDenun, hora, tipo and des of $rootScope.

  • Fine, but what should I check on that data? I have to erase their data after the display?

  • 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.

  • I must set these variables to null after the map is displayed with this information?

  • This information comes from a form, which the user fills in.

  • You can monitor the user’s changes, and change the property content of infowindow to display the new values.

  • Putzzz, but how do I do it?

  • 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.

  • 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.

Show 3 more comments

0

  • But that’s not what I want, not with regard to brand, but with regard to the information that appears.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.