how to get same geo code for an address which is in bing map through bing map API? - bing

I have an address which shows correct correct place in bingmap. When I request geo code for same address using Unstructured URL API, it sends different geo location
address:
86 Oakleaf Dr Meadow Valley, CA 95956
when I request through bing map api
https://dev.virtualearth.net/REST/v1/Locations?CountryRegion=us&adminDistrict=CA&locality=Meadow%20Valley&postalCode=95956&addressLine=86%20Oakleaf%20Dr&output=json&key=BingmapKey
It result somewhere here
am I missing anything in API request? (I have valid bing key)

https://dev.virtualearth.net/REST/v1/Locations?CountryRegion=us&adminDistrict=CA&locality=Meadow%20Valley&postalCode=95956&addressLine=86%20Oakleaf%20Dr.&output=json&key=BingMapsKey
What you have seems right, I just added a period after the 'Dr' and it changed it to the correct location you wanted.

I changed API calling
Find a Location by Address to Find a Location by Query and it sends same geo location which when we search address in bingmap website.
No other solution I could found in Find a Location by Address API.
var url = "https://dev.virtualearth.net/REST/v1/Locations?query="
+ encodeURIComponent('Oakleaf Dr Meadow Valley CA 95956 United States')
+ "&incl=queryParse"
+ "&output=json"
+ "&key=" + BingmapKey

Related

Bing Maps throwing "Invalid Geocode" error on street intersection that it is able to get the Latitudes and Longitude from

I am currently working on a project that involves calculating Duration matrices from a collection of thousands of addresses using NEO4J and Bing Maps API. Since the data is sensitive, we're going to use the mock address (which actually produces the same issue I'm describing) '72ND & DODGE, OMAHA, NE 68132' to represent the format intersection addresses are being sent to Bing Maps API using their keys and basic url requests.
To preface this: the issue isn't with my code (which is also sensitive data), as all my code is doing is sending one url string of the above format plus the authorization key to Bing Maps and awaiting a response that contains the duration data of the trip. My issue is Bing Maps being seemingly unable to handle or work with intersections of streets to calculate distances/durations from other locations. When I throw these addresses into Bing/Google Maps in the web browser, they are able to be found and calculated in the exact same format as the above example.
I start off my program checking if an address exists/is valid by having it find the latitude and longitude of each address, so for the example '72ND & DODGE, OMAHA, NE 68132' it found: Lat: '41.259690' and Long: '-96.023770'. If it is unable to find the Lat/Long of an addresses, then it throws the 'Invalid Geocode' error, but in this initialization context it means the address does not exist, or is poorly formatted, which makes sense and is why I did this for the initialization phase.
However, if I go to use '72ND & DODGE, OMAHA, NE 68132' for any duration calculations between other addresses, it throws the 'Invalid Geocode' for '72ND & DODGE, OMAHA, NE 68132' over and over again with no explanation on why even though it passed the Lat/Long check. I'd also like to mention that this issue isn't consistent, as some intersections do not work while others do, but there is no consistency in knowing which ones will or will not work. Thus, I am ultimately wondering if Bing Maps is unable to calculate certain addresses no matter their formatting or whatnot.
Be sure to encode your query before putting it into the URL. Especially when you have & in your query since it would then break your query up, thinking you were asking just for 72ND and the rest of your query is query string parameter name. This is documented in the best practices section here.
In Java you can encode the query parameter like this:
String baseURL = "https://dev.virtualearth.net/REST/v1/Locations?key={BingMapsKey}&query=";
// query string
String query = "72ND & DODGE, OMAHA, NE 68132";
// URL encode query string
String encodeStr = URLEncoder.encode(query, StandardCharsets.UTF_8.name());
// final url
String url = baseURL + encodeStr;
Here is an example of how your query URL should look:
https://dev.virtualearth.net/REST/v1/Locations?key={BingMapsKey}&query= 72ND%20%26%20DODGE%2C%20OMAHA%2C%20NE%2068132

How to add housenumber in nominatim API in OSM

The Nominatim API states
'street= '
It implies that there is a space between <housenumber> and <streetname>.
However, when I try to enter a space in the URL
https://nominatim.openstreetmap.org/search?city=berlin&street=skalitzerstrasse 9&format=json
I get an error (understandable).
How to properly add the housenumber?
First of all it's better to prefix the housenumber and than you just urlencode the space like:
https://nominatim.openstreetmap.org/search?city=berlin&street=142%20skalitzer%20straße&format=json
You'll also have only the street as a response if a housenumber (like 9) is not present or mapped, that's why I have chosen a different housenumber as an example.

How to get a static map searching by city with an specific country

I'm trying to get a map img from Google Static Maps API,
If I do the following requests:
https://maps.googleapis.com/maps/api/staticmap?size=1536x836&center=+Spain,+Andorra&zoom=8&markers=color:red%7Clabel:D%7C,+Andorra+Spain&key=badKey
center and label variations: +Andorra,+Spain , +Andorra,+ES, +Spain+Andorra, +Andorra+Spain
I get always Andorra La Vieja, country Andorra,
I expect to get Andorra, Spain,
The only way I could obtain Andorra Spain is specifying the state / province (Teruel).
Upon checking, this behavior is working as intended which can also be replicated in Geocoding API using the Geocoder tool which returns the country "Andorra" when geocoding the address "Andorra, Spain".
Since the address string "Andorra, Spain" is slightly ambiguous, and there are two addresses that contains "Andorra", the API was only able to return the country Andorra. To have better results, you need to be more specific with your query by also providing the admin levels "Teruel" or "Aragon" or a postal code, as you have also mentioned in your post. See full address result here.

latitude longitude of Address

I am finding the latitude and longitude of a Address 4760 matric Drive, winter park, FL, 32792 and bing map giving lat long 28.604771, -81.292976. This same i am doing with my request from URL and the url is http://dev.virtualearth.net/REST/v1/Locations?countryRegion=USA&adminDistrict=FL&locality=&postalCode=32792&addressLine=4760%20matric%20Drive&key=Mykey&output=xml
This is response me the lat long
<Latitude>28.610404968261719</Latitude>
<Longitude>-81.2994155883789</Longitude>
Why the same address are different Lat Long from bing map. Please give me advice.
Trying both forms of the address in the REST services I'm getting the exact same result which is the second set of coordinates you provided. The reason for this is that the geocoder matched the postal code and not the road.
The Bing Maps website returns the first result you mentioned but the website is using a completely new geocoder that is currently being tested before being used on the backend of the developer API's.

Mapquest route matrix response

Hi I am using mapquest api to show the distance from source to destination in app
Problem:
I am sending below request to mapquest to get the distance
{ "locations":[ "40.2336,-111.6475", "33.621227,-111.917229","30.688181,76.706238"],
"options":{ "allToAll":true, "unit":"k", "doReverseGeocode":false,"manyToOne":true } }
Now in this case distance can be calculated from first lat long to second lat long as both are US based address but distance cannot be calculated between first and third location as third one is Indian location .
Now the response I am getting is
{"route":{"routeError":{"message":"","errorCode":0}},"info":{"copyright":
{"text":"© 2015 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif",
"imageAltText":"© 2015 MapQuest, Inc."},"statuscode":400,
"messages":["We are unable to route with the given locations."]}}
Which I suppose is wrong as distance between first two places should be returned .
Please suggest what can be done for this ?
Currently the matrix fails if any of the legs fails. Making this return any successful legs is on the team's backlog.
The reason for the error is that your locations are invalid. I ran it with the exact POST body you had, and got error 402. Looking at the MapQuest Directions API Status Codes, this is an invalid location. This makes sense, considering the coordinates include two in the US and one in India. This, AFAIK, is only a driving API, hence why overseas locations are invalid.
Another point unrelated to the main problem: your request is semantically invalid. You specify both allToAll and manyToOne as true, which is invalid. The API will ignore your manyToOne as a result, so make sure you are requesting exactly what you want.