Hide Polygon RRS feed

  • Question

  • Having problems with V8, creating ploygons dynamically but can't hide them now!
    Any ideas?



    Code example:

    function addPolygon()
    // .... code above removed, it puts the lat and lng into the var 'pts' from an xml doc 
      polyshape = new Microsoft.Maps.Polygon(pts, { fillColor: polygoncolor, strokeColor: polygoncolor });
                // Add the polygon to the map
                group2[number].setOptions({ visible: true });
                // Add the shape to the map
    function hideCategory(number, groupname) 
       //original code for v7 - no longer hiding the entity
       group2[number].setOptions({ visible: !group2[number].getVisible() });
       //tried this - doesn't work either 
       group2[number].setOptions({ visible: false });
        //try deleting polygon by id
        var entityname = group2[number]._id;//find entity name from collection
    	//this doesn't work as entities have no IDs to access
        //var indextodel = map.entities.indexOf(entityname);
    	//this is what is what is given as an example in V8
    	//not very useful as can't find out the identity of each layer (polygon) 
    	for (var i = map.entities.getLength() - 1; i >= 0; i--) 
            var polygon = map.entities.get(i);
            if (polygon instanceof Microsoft.Maps.Polygon) 

    Thursday, December 15, 2016 12:22 PM