Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript map in leaflet how to refresh
    text
    copied!<p>i have a basic geoJson program in javascript by using leaflet API. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" /&gt; &lt;script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"&gt;&lt;/script&gt; &lt;script src="india.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id = "map1" style="width: 1100px; height: 400px"&gt; &lt;/div&gt; &lt;script&gt; var area = L.map('map1', {center: [27.8800,78.0800], zoom: 4 }); L.tileLayer('http://a.tiles.mapbox.com/v3/raj333.map-gugr5h08/{z}/{x}/{y}.png').addTo(area); var indiaLayer= L.geoJson(india, {style: {weight: 2, opacity: 1, color: 'white', dashArray: '3', fillOpacity: 0.1}}); area.addLayer(indiaLayer); function clicked(){ this.options.style.fillOpacity = 0.8; //how to refresh layer in the given map } indiaLayer.on('click', clicked); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>the problem is how would i automatically refresh the content of Layer on the map.</p> <p>example here </p> <pre><code> function clicked(){ indiaLayer.style.fillOpacity = 0.8; //how to refresh layer in the given map } indiaLayer.on('click', clicked); </code></pre> <p>when user click on indiaLayer , the fillOpacity variable changes but doesn't reflect back on map which is understood since i am not refreshing the map. I don't know how to do it. </p> <p>please help </p> <p>P/s: these are the functions available on indiaLayer object (i.e. this object inside clicked function...which one to use for this purpose or there exist none)</p> <p>You can check the list of methods available of GEOJson in the <a href="http://leafletjs.com/reference-0.7.7.html#geojson" rel="nofollow noreferrer">Leaflef documentation</a> This is the link to v.0.7.7, which is the closest available to used in this example.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload