none
Bing Maps V8 - Polygons are flashing occasionally while zooming in and zooming out RRS feed

  • Question

  • Hi Team,

    We are binding the list of polygons to the map using layer object.

    After clearing the layer i.e, using layer.clear() the polygons were deleted successfully.

    Then while zooming in and zooming out, the polygons are flashing occasionally.

    Please advise do we have any workaround for this issue.

    Thanks,

    Anil Pandilla

    Wednesday, August 14, 2019 11:23 AM

All replies

  • Hi Anil,

    It sounds like you are not actually removing the layer but I have a sample that does use the same method and does not flash.  See https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/cleargroundoverlay

    Sincerely,

    IoTGirl 

    Wednesday, August 14, 2019 4:34 PM
    Owner
  • Hi,

    Please find the below code for binding the polygons using layer.

    Code:

    static BindGeofencePolygons(fences) {       

            //Create a layer for the drawn shapes.
            fenceLayer = new Microsoft.Maps.Layer();  
            
            $.each(fences, function (selectedIndex, selectedValue) {
                var exteriorRing = selectedValue.FormatedCoordinates;
                var selectedFence = selectedValue;           
                //var historyId = selectedValue.GeofenceHistoryID;
                var polygon;
                if (selectedValue.GeofenceCategoryCd == "B")
                    polygon = new Microsoft.Maps.Polygon(exteriorRing, { strokeDashArray: [1, 3] });
                else
                    polygon = new Microsoft.Maps.Polygon(exteriorRing, null);

                fenceLayer.add(polygon);            

                Microsoft.Maps.Events.addHandler(polygon, 'mousedown', function (args) { displayFenceInfoboxOnClick(args, selectedFence, polygon); });
            });

            reeferMap.layers.insert(fenceLayer);       
     }

    To clear the layer we are calling fenceLayer.clear();

    Please let us know how we can replace/modify the above code with below sample.

    https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/cleargroundoverlay

    Thanks,

    Anil Pandilla

    Monday, August 19, 2019 6:19 AM
  • Hi Anil,

    Would you be able to share how you are implementing .clear() in your code?

    Cheers,

    John

    Tuesday, August 20, 2019 2:42 PM
    Moderator
  • Hi John,

    Please find below function for clearing polygons.

    static ClearFenceLayer() {

    if (fenceLayer != null) {
                fenceLayer.clear();
            }

    }

    Thanks,

    Anil Pandilla

    Wednesday, August 28, 2019 5:56 AM