Find polygon within proximity

Balasaheb Molawade 136 Reputation points


We have developed an application using Bing map in that we have the requirement to show areas ( plotted area using polygon) that are covered by specific proximity say suppose 5 miles. For example, we have plotted area as a polygon now we wanted to show the area that covers by proximity search as shown below. We wanted to show all polygon those are touched the proximity circle.


In any one have the best solution to show area within proximity.

Waiting for your reply.  


Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
249 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. rbrundritt 15,546 Reputation points Microsoft Employee

    To achieve this you will need to loop through all your polygons and do an intersection test with your proximity circle polygon. Since you are using the Bing Maps V8 web SDK, you can use the spatial math module to do the intersection test. Here is a quick example.

    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialMath', function () {
    	//Assume this is an array of polygons.
    	var polygons = [];
    	//Assume this is the polygon area you want to search in (i.e. circle);
    	var searchPolyogn = {};
    	//Loop through each polygon.	
    	for(var i=0,len=polygons.length; i < len; i++){
    		//Test each polygon to see if it itersects the search polygon.
    		if(Microsoft.Maps.SpatialMath.Geometry.intersects(polygons[i], searchPolyogn)){
    			//If it does, do something, like change it's color. 
    			polygons[i].setOptions({fillColor: 'red' });
    		} else {
    			//It didn't intersect, maybe change the color back to a default color.
    			polygons[i].setOptions({fillColor: 'blue' });

    Here is a similar example:

    1 person found this answer helpful.

  2. IoTGirl 2,976 Reputation points Microsoft Employee

    Hi Balasaheb,

    Your screen shot does show which polygons are touched by the circle so I would like a better understanding of what you are looking to actually show. Rather than random distance circles, we see customers using distance isochrones like this Isochrone Demo does. Note that the pins within the isochrone are recolored each time the isochrone is calculated. You could do the same for whatever object type you want to color.

    There is a similar example at