How to modify a JSON file with Javascript?

Asked

Viewed 236 times

0

I am using the Mapbox. When you click on a Poligono appears the name of the person who lives in the city. But I want when I click to change the name of the person in the JSON file.

map.on('click', function(e) {

var features = map.queryRenderedFeatures(e.point, {
            layers: ['counties']
        });

var feature = features[0];


          $.getJSON('features.geojson', function(data) {

              feature.properties.nome = "JUBILEU";

         });

$('#QuestaoModal').modal('show');


});

But wrong that way, it’s not working

  • Is this JSON file a file on the server? That’s what you want to change?

  • Actually it is in the same php/html project folder that runs on a local server (on my machine), wamp server

  • And I want to change the object, give it another name etc

  • this has a bit of logic in the server and another in the browser. You know how to solve some of them?

  • I don’t know how to fix :/

No answers

Browser other questions tagged

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