Extending road data in Azure Maps with custom data for wayfinding

I'm currently using Azure Maps for visualization of objects inside a private area and I'd like to add custom road-data (e.g. in geojson) to add wayfinding inside that area. I see that there's an Azure Maps sample for this ( However, is it also possible to 'extend' the existing Azure Maps routing service with this custom data, such that a user can create a route from outside the area to somewhere inside of the area?


  • There are several ways to achieve this, however, note that there is no built-in method for integrating custom routing networks with the Azure Maps (or most other map platforms) routing services.

    That said, there are several ways to create a solution that does a good job of combining two solutions. Here are the steps to create such a solution:

    1. The first question I would ask is how big and complex is your custom network? And where do you need to surface the solution. In the sample you referenced, it is using GeoJSON files and calculating the route paths in the frontend web app. That will work fine for most smaller route networks, and if you don't need to do any additional processing/calculations on the route path server side (like buffer it and fine nearby objects in some database that are along the route), this would work fine. If however you have a more complex route, possibly with more complex restrictions (one ways, sections only available during certain times of the day, security pass required...), or you need to do additional processing on the server side, then it would be best to put this route network into a spatial database and calculate that portion of the route there. PostgreSQL has a plugin called pgRouting that provides the ability to calculate routes on custom networks in the database. There are other routing plugins available, but this is the most commonly used one.
    2. Now once you decide on one of the two above approaches, the next step is to analyze your route, and find where that route would intersect with public access roads that would typically be available in map platforms and capture these points. Depending on the size of your routing network this may be a fairly small number and something that could be manually captured. The points don't need to be exact, but ideally would be between the end of your custom road lines and the public road lines (a gap between these roads is fine as we would just assume they connect later in the calculation). 3.The next step is to create the solution that combines the map platforms routing with your custom routing. This is a bit of code that would wrap both solutions and provide a single API for you to call into. Take the start and end points that are inputted by the user. Determine each of these are within your custom route network, or the public route network. Assuming you have input coordinates, calculate the distance to the nearest line in your custom route network. If it is within some small distance (usually < 150m works well), assume it is inside your routing network. Keep track of this nearest point as that will be the routing point used by the custom routing solution. If the point is further away, assume it is outside of your custom network.
    3. Compare the two points, are they both within your custom network, if so, you only need to use your custom routing solution. Otherwise, is one of the points within your custom network, and is it the starting or ending point? If both points are outside of your custom network, use the map platforms routing service only.
    4. Assuming one point in, and one out of your network, you now need to choose one of the points from #3 where your network connects to the public road network. There are different ways to do this. A simple option is to take the point that's inside your network and choose the point from #3 that is the closest, that way you get out of your network the quickest. You could alternatively choose the point closest to your end point, that way you are hypothetically travelling towards the destination. You could also add some metadata to the points in #3 and prioritize them. You may find that one route is ideal for those who are going to travel longer distances as it provides quick access to a highway. Or you may lower the priority of a point as it intersects with a busy road and takes forever to make turns. You may also want to take into consideration if the road has separated lanes as that may make it harder if traveling from one direction or another.
    5. Now you should have three points that form two route sections; start -> network connection point, network connection point -> end. Assuming you want to let people route in and out of your network, use the information in #4 to determine which routing solution to use for each section. For sections that have a point on public roads, use the map platforms routing service. For sections that have a point within your network, use your routing solution. Take the route path data from each solution (line of coordinates), and simply append the second route section line to the first one and this will provide you with the complete path (with a straight line connecting any small gap between the public road network and your network).