none
Get search area to find locations near the route RRS feed

  • Question

  • Hi,

    We have collection of locations from which we want to search locations near of the route. We are  using Microsoft.Maps.SpatialMath.Geometry.buffer to get search area. We are passing parameters as Microsoft.Maps.SpatialMath.Geometry.buffer(currentroutepath, routedistance, distanceUnit). However we noticed that when we pass distance unit as miles it search less locations than the kilometer. Locations should be get more in miles as miles is greater than kilometer. We are passing the distanceunit number i.e 1 for miles and 2 for kilometers.Could you please help us know what is the main issue?

    Thanks in advance!

    Monday, March 19, 2018 2:39 PM

Answers

  • When working with SpatialMath library, SpatialMath distance units need to be used, instead of Directions distance units.

    i.e.
    Microsoft.Maps.SpatialMath.DistanceUnits.Miles
    Microsoft.Maps.SpatialMath.DistanceUnits.Kilometers
    instead of 
    Microsoft.Maps.Directions.DistanceUnit.miles

    Microsoft.Maps.Directions.DistanceUnit.km

    Test this out in your application and let me know if it works. 

    Thursday, March 29, 2018 8:57 PM
    Moderator

All replies

  • I just tested the buffer method with all the distance unit parameters in a sample application which works fine. The radius is bigger with miles. Can you share some code on how you are doing this?
    Monday, March 19, 2018 5:53 PM
    Moderator

  • Thanks for reply.

    To get the buffer we wrote below code:

    var getCurrroute = directionsManager.getCurrentRoute(); //get current plotted route
    var routePath = new Microsoft.Maps.Polyline(getCurrroute.routePath); //get the route path
    var searchArea = Microsoft.Maps.SpatialMath.Geometry.buffer(routePath, 5, 1); //search area 

    To search location near route we wrote below code:

    var intersectLocs = Microsoft.Maps.SpatialMath.Geometry.intersection(locations, searchArea);

    Thanks in advance!

    Friday, March 23, 2018 9:18 AM
  • Hello Vikas,

    I'll escalate this to the team as it does appear to be an issue from the sample I created.

    Friday, March 23, 2018 5:19 PM
    Moderator
  • Thanks for the reply,

    Do you have any idea when this issue will get resolve because our project will go live next week? We need to get this resolved ASAP.

    Thanks again.

    Tuesday, March 27, 2018 3:34 PM
  • When working with SpatialMath library, SpatialMath distance units need to be used, instead of Directions distance units.

    i.e.
    Microsoft.Maps.SpatialMath.DistanceUnits.Miles
    Microsoft.Maps.SpatialMath.DistanceUnits.Kilometers
    instead of 
    Microsoft.Maps.Directions.DistanceUnit.miles

    Microsoft.Maps.Directions.DistanceUnit.km

    Test this out in your application and let me know if it works. 

    Thursday, March 29, 2018 8:57 PM
    Moderator
  • Thank you.

    It works and once again thank you.

    Friday, March 30, 2018 2:19 PM