none
How to reset selected GeoJson's strokeColor RRS feed

  • Question

  • Hi,

    I have some GeoJson files that I overlaid on Bing Map.  When a user selects an overlaid shape, the outline color of the shape changes to orange.  My problem is, when another shape is selected, how do I make the previous selection's color just "revert" back to Bing's default outline color?  Below is my code snippet:

    //Load GeoJSON module.
    var geoFile = "/data/geo/" + st + "/" + cntyName + ".json";

    Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () { //Read the GEOJSON file that is hosted on the same domain Microsoft.Maps.GeoJson.readFromUrl(geoFile, function (data) { //Loop through the data for (var i = 0; i < data.length; i++) { //Add a click event to each data Microsoft.Maps.Events.addHandler(data[i], 'click', function (e) { if (data[i] = e.target) { data[i].setOptions({ strokeColor: 'orange', strokeThickness: 5 }); } else { data[i].setOptions({ strokeColor: 'blue', strokeThickness: 1 }); } }) } //Add results to the map map.entities.push(data); //reset map view var rect = Microsoft.Maps.LocationRect.fromShapes(data); map.setView({ bounds: rect, padding: 2 }); }); });



    Marilyn Gambone

    Wednesday, January 29, 2020 10:07 PM

All replies