Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Get longitude and latitude with public place names - Bing Maps API

Hello,

 

I have a list of public places, for example store names, hospital names, government buildings.

 

I would like to get the latitude and longitude from these names. I have tried this tutorial https://www.youtube.com/watch?v=YxwU5UubWjI but instead of addresses I put in the store names + city + country but the longitude and latitude that comes out is incorrect.

 

I tried to input the same store names + city + country into Bing Maps itself and it works just fine:

 

phuogh_0-1632990738328.png

phuogh_1-1632990758851.png

 Is this possible to achieve?

 

Thank you beforehands 🙂

3 REPLIES 3
rouvenor
New Member

did you ever find a solution?

Anonymous
Not applicable

Hi @Anonymous 

I think the first way is the workaround. Is your issue that when you invoke custom function, you will get incorrect result? There may be some differencet locations with same name in same country and city. You can add more details in your location.

If you still want to get data by Way 2, please refer to the post as below and try this code.

let

    FindLatLong = (location) =>

let
    Source = Xml.Tables(Web.Contents("http://dev.virtualearth.net/REST/v1/Locations/"&location&"?o=xml&key=XXX",
        [ManualStatusHandling={404}])),
        GetMetadata = Value.Metadata(Source),
        GetResponseStatus = GetMetadata[Response.Status], 
        Output = if GetResponseStatus=404 then "Error!" else Source,
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Copyright", type text}, {"BrandLogoUri", type text}, {"StatusCode", Int64.Type}, {"StatusDescription", type text}, {"AuthenticationResultCode", type text}, {"TraceId", type text}}),
        ResourceSets = #"Changed Type"{0}[ResourceSets],
        ResourceSet = ResourceSets{0}[ResourceSet],
        #"Changed Type1" = Table.TransformColumnTypes(ResourceSet,{{"EstimatedTotal", Int64.Type}}),
        Resources = #"Changed Type1"{0}[Resources],
        Location = Resources{0}[Location],
        #"Changed Type2" = Table.TransformColumnTypes(Location,{{"Name", type text}, {"EntityType", type text}, {"Confidence", type text}, {"MatchCode", type text}}),
        Point = #"Changed Type2"{0}[Point],
        #"Changed Type3" = Table.TransformColumnTypes(Point,{{"Latitude", type number}, {"Longitude", type number}})
in
    #"Changed Type3"

in

    FindLatLong

For reference: Power Query Function Error Bing Maps API Token Literal Expected Error when 404 is returned

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I have found the Bing Maps API also offers the finding of such places using LocalSearch.

 

Source = Json.Document(Web.Contents("https://dev.virtualearth.net/REST/v1/LocalSearch/",[RelativePath=NameOfLocation,

    Query=[
         userMapView="xxxx,yyyy,zzzz,wwww",
         key="xxxxxxxxxx"
    ]
]),TextEncoding.Utf8),

 

The error is 404 Not Found

 

DataSource.Error: Web.Contents failed to get contents from 'https://dev.virtualearth.net/REST/v1/LocalSearch/Name%20Of%20Place?userMapView=xxxx%2Cyyyy%2Czzzz%2w...' (404): Not Found

 

How can I fix this issue?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.