none
Bing Maps SpatialMath Module Intersection is not accurate with Multiple pins with same coordinates RRS feed

  • Question

  • I figured an issue, while i have thousands of pins over the map, i am using drawing tool to draw shapes free hand and then executing the Intersection on "drawingEnded" event, While i could see the intersection should return more than it actually returns, 

    Am i missing something ? For Example, If there are around 500 pins under the new area drawn, Intersection method only returns 100 or few more,

    Intersection Function Code which gets triggered after "drawingEnded" event:
    `        function findIntersectingData(searchArea) {
                //Ensure that the search area is a valid polygon, should have 4 Locations in it's ring as it automatically closes.
                if (searchArea && searchArea.getLocations().length >= 4) {

                    //Get all the pushpins from the pinLayer.
                    //var pins = spiderManager._data;

                    //Using spatial math find all pushpins that intersect with the drawn search area.
                    //The returned data is a copy of the intersecting data and not a reference to the original shapes, 
                    //so making edits to them will not cause any updates on the map.
                    var intersectingPins = Microsoft.Maps.SpatialMath.Geometry.intersection(pins, searchArea);
                    //The data returned by the intersection function can be null, a single shape, or an array of shapes. 
                    if (intersectingPins) {
                        //For ease of usem wrap individudal shapes in an array.
                        if (intersectingPins && !(intersectingPins instanceof Array)) {
                            intersectingPins = [intersectingPins];
                        }
                        var selectedPins = [];
                        //Loop through and map the intersecting pushpins back to their original pushpins by comparing their coordinates.
                        for (var j = 0; j < intersectingPins.length; j++) {
                            for (var i = 0; i < pins.length; i++) {
                                if (Microsoft.Maps.Location.areEqual(pins[i].getLocation(), intersectingPins[j].getLocation())) {
                                    selectedPins.push(pins[i]);
                                    break;
                                }
                            }
                        }
                        //Return the pushpins that were selected.
                        console.log(selectedPins);
                        return selectedPins;
                    }
                }
                return null;
            }
    `

    The function is not returning accurate pin data,
    Am i missing something here ?

    It is an assumption ,I have multiple pins with same coordinates over the layer, Is this the reason that it returns only pins which intersects with different coordinates over the map ?, If Yes, How do i avoid that ?

    Thanks & Regards,
    Shohil Sethia
    Wednesday, August 29, 2018 9:29 PM

All replies