Loading...

Azure Maps REST SDKs

Azure Maps REST SDKs

Azure Maps is more than just a Map on your website. It is a complete enterprise solution for location-aware solutions. For example, you can do (reverse) geocoding of customer addresses and use an isochrone to find out withs customers a close to your store or get weather conditions for all your past sales data to know withs products sell best by rain or hot weather or get the correct time-zone for your customer by translating an IP-address to a location and get the time-zone information, or you need to know what the travel time is between two or more locations. So many scenarios and use cases you can make location aware with Azure Maps.

 

You can call the Azure Maps REST APIs directly from any programming language, which is not difficult but always needs extra work. With the introduction of the public preview Azure Maps REST SDKs for C# (.NET), Java, Phyton, and TypeScript (Node.js), you can earlier use the power of Azure Maps in your backend without the hassle of calling the APIs the correct way.

 

To give you a simple example in C#, we are searching for a Starbucks close to a customer's location in Seattle. Before we can begin, you need an Azure Maps key; see here how to get a free Azure Maps key.

 

The following code snippet creates a console program MapsDemo with .NET 7.0. You can use any .NET standard 2.0-compatible version as the framework.

 

dotnet add package Azure.Maps.Search --prerelease

 

The following code snippet demonstrates how, in a simple console application, to import the Azure.Maps.Search package and perform a fuzzy search on “Starbucks” near Seattle. In the Program.cs file add the following code:

 

using Azure; using Azure.Core.GeoJson; using Azure.Maps.Search; using Azure.Maps.Search.Models; // Use Azure Maps subscription key authentication var credential = new AzureKeyCredential("Azure_Maps_Subscription_key"); var client = new MapsSearchClient(credential); SearchAddressResult searchResult = client.FuzzySearch( "Starbucks", new FuzzySearchOptions { Coordinates = new GeoPosition(-122.31, 47.61), Language = SearchLanguage.EnglishUsa }); // Print the search results foreach (var result in searchResult.Results) { Console.WriteLine($""" * {result.PointOfInterest.Name} {result.Address.StreetNumber} {result.Address.StreetName} {result.Address.Municipality} {result.Address.CountryCode} {result.Address.PostalCode} Coordinate: ({result.Position.Latitude:F4}, {result.Position.Longitude:F4}) """); }

 

In the above code snippet, you create a MapsSearchClient object using your Azure credentials, then use that Search Client's FuzzySearch method passing in the point of interest (POI) name "Starbucks" and coordinates GeoPosition(-122.31, 47.61). This all gets wrapped up by the SDK and sent to the Azure Maps REST endpoints. When the search results are returned, they're written out to the screen.

 

To run your application, go to the project folder and execute dotnet run in PowerShell.

 

More information you can read in our Azure Maps REST SDK Developer Guide. Happy coding!

Published on:

Learn more
Azure Maps articles
Azure Maps articles

Azure Maps articles

Share post:

Related posts

Announcing Azure Cosmos DB Integration with LangChain.js!

Announcing Azure Cosmos DB Vector Store Integration with LangChain.js! We’re simplifying AI app development by integrating Azure Cosmos ...

6 hours ago

Scale Your Database Workloads with Multishard Clusters in vCore-based Azure Cosmos DB for MongoDB

We’re excited to introduce significant enhancements to vCore-based Azure Cosmos DB for MongoDB with the release of multishard clusters preview...

6 hours ago

Transform Your Azure Container Apps with Bulletproof Security

In this post, we explore how to transform your Azure Container Apps with unshakable security. Learn how to master secrets management, optimize...

20 hours ago

Optimize Azure Landing Zone with Azure Virtual Network Manager IP Address Management

Optimize Azure Landing Zone with Azure Virtual Network Manager IP Address Management What you will learn from this blog This blog explores how...

1 day ago

Announcing UNLIMITED Public Preview of Metadata Caching for Azure Premium SMB/REST File Shares

Azure Files is excited to announce the Unlimited public preview of Metadata Caching for the premium SMB/REST file share tier.  Unlimited ...

1 day ago

Dominate your industry and boost performance using Azure AI tools and skilling

As AI technologies continue to rapidly evolve, developers have the exciting opportunity to stay ahead by continually learning and adapting. Wi...

1 day ago

Azure DevOps – EPICS vs FEATURES vs USER STORIES vs Tasks vs Bugs

Today, we’re diving into Epics, Features, User Stories, Tasks and Bugs and the main differences between them. You will learn when to use...

2 days ago

Discover the New Azure Cosmos DB Samples Gallery!

We are thrilled to introduce the Azure Cosmos DB Samples Gallery —your ultimate destination for top-tier Azure Cosmos DB samples, technical gu...

2 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy