cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jvdlinden
Level 8

Bing Maps API issue

Dear all,

 

I am currently trying to add a Mileage Tracking function to a PowerApp app we use in our organization.

Therefore I am using the Bing Maps connector. I have signed up to the Bing Maps Dev Center using my Microsoft-account and created a new key.

 

Next, I have added the key to the PowerApps Connections menu. 

 

Next, I have added two TextInput controls to the screen TextInput1 and TextInput2. 

TextInput1.Default = Location.Latitude

TextInput2.Default = Location.Longitude

 

At last I have added a Label (Label1) to the screen, which converts the coordinates to a formatted address.

This is how:

Label1.Text = BingMaps.GetLocationByPoint(TextInput1.Text,TextInput2.Text).address.formattedAddress

 

For me, this works perfectly fine! For my colleagues not. Somehow it does not convert the coordinates to a formatted address. One colleague told me that he was getting some kind of an error concerning the API.

 

I have tried to reach out to Office 365 PowerApps Support, but they told me that they couldn't help me out with that and that I could better try here on the community.

 

Hopefully someone has already dealt with this issue.

 

Thanks for any help,

Joost

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Bing Maps API issue

What is likely happening is that PowerApps is sending the lat/long coordinates formatted with the ',' decimal separator (based on the other messages, I'm assuming your users are in the nl-NL region/locale wihch uses that separator - I've had the same problem while running in the pt-BR locale, which has the same decimal separator), while BingMaps expects it to have the '.' decimal separator. The type of the arguments to the BingMaps.GetLocationByPoint API is string, so if you call it as such:

BingMaps.GetLocationByPoint(Location.Latitude; Location.Longitude)

Then it will convert those values (lat/long) to string prior to calling it - and the default string conversion uses the separator of the current locale - so that will be equivalent to

BingMaps.GetLocationByPoint("51,586479"; "4,829391")

Which the Bing Maps connector doesn't like. To make this scenario work, you can force it to encode the numbers with the decimal separator that is expected by the connector:

BingMaps.GetLocationByPoint(
    Text(Location.Latitude; "[$-en-US]0.000000"; "en-US");
    Text(Location.Longitude; "[$-en-US]0.000000"; "en-US"))

And with this, I can get the proper formatted address for my location.

3 REPLIES 3
KroonOfficeSol
Level 10

Re: Bing Maps API issue

Hallo Joost,

 

I think this is just not possible to make this work in the way you want, because simple there is no address available for the coördinates you have.

To check I put the coöridated off the wrong result directly in the browser and there is no adress for this point. Result is this: 

  • Netherlands
  • North Brabant
  • Gemeente Breda
  • Breda
51.586479, 4.829391
 
So mayby the way to go is to work with the result in a way that you check the address first and when there is no matching result you then grab the city and display this. Then Breda would probably be returned.
 
Didn't work with this connector yet, but I am surtain that this will work.
 
Hoop dat je hier iets aan hebt. Groet,
 
Paul
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Bing Maps API issue

What is likely happening is that PowerApps is sending the lat/long coordinates formatted with the ',' decimal separator (based on the other messages, I'm assuming your users are in the nl-NL region/locale wihch uses that separator - I've had the same problem while running in the pt-BR locale, which has the same decimal separator), while BingMaps expects it to have the '.' decimal separator. The type of the arguments to the BingMaps.GetLocationByPoint API is string, so if you call it as such:

BingMaps.GetLocationByPoint(Location.Latitude; Location.Longitude)

Then it will convert those values (lat/long) to string prior to calling it - and the default string conversion uses the separator of the current locale - so that will be equivalent to

BingMaps.GetLocationByPoint("51,586479"; "4,829391")

Which the Bing Maps connector doesn't like. To make this scenario work, you can force it to encode the numbers with the decimal separator that is expected by the connector:

BingMaps.GetLocationByPoint(
    Text(Location.Latitude; "[$-en-US]0.000000"; "en-US");
    Text(Location.Longitude; "[$-en-US]0.000000"; "en-US"))

And with this, I can get the proper formatted address for my location.

jvdlinden
Level 8

Re: Bing Maps API issue

@CarlosFigueira,

Awesome. That did the trick. Thank you so much! 

I would have never figured that out myself.

 

I've tested on both my work and private notebook. Both work fine now.

 

I'm assuming that it will now work perfectly on all other devices as well. But I will check :-)

 

Side note: as you mentioned something about the regional formatting. My work notebook has been installed with English OS but Dutch formatting (as far as I could see), my personal notebook Windows (Dutch only).

All other devices I tested on were also installed using Dutch language.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 23 members 4,252 guests
Please welcome our newest community members: