Home > other >  Azure Maps API - Search for location based on ID
Azure Maps API - Search for location based on ID

Time:08-18

I am working with the Azure Maps API, which returns information for a "fuzzy" match in this format:

{
    type: 'Geography',
    id: 'US/GEO/p0/52503',
    score: 2.7559998035,
    entityType: 'PostalCodeArea',
    address: {
      municipalitySubdivision: 'Brentwood',
      municipality: 'Washington',
      countrySecondarySubdivision: 'District of Columbia',
      countrySubdivision: 'DC',
      countrySubdivisionName: 'District of Columbia',
      postalCode: '56967',
      postalName: 'Parcel Return Service',
      countryCode: 'US',
      country: 'United States',
      countryCodeISO3: 'USA',
      freeformAddress: 'Parcel Return Service, DC 56967'
    },
    position: { lat: 38.91752, lon: -76.99356 },
    viewport: { topLeftPoint: [Object], btmRightPoint: [Object] }
  }

I want to be able to store the id property in a database (US/GEO/p0/52503 in this case) and then be able to get all the information from Azure without needing to basically duplicate the Azure data. I couldn't find any information in the Azure Maps API documentation about how to do a lookup for a location based on this ID - is this possible?

CodePudding user response:

The is no way to retrieve results by ID in Azure Maps. Additionally, there is no guarantee that the ID will not change in the future (the V2 geocoding service doesn't have the ID). I believe it is mainly there for debugging purposes.

Storing the Address and optionally the lat/lon values in your database is likely the best option. Note that as long as you have an Azure subscription and your database is in Azure, you can store the lat/lon result data in your database (even if you aren't using Azure Maps anymore).

  • Related