How to find a adress from GPS coordinates via API OpenStreetMap?
I can use any language (javascript, java, ...)
Reverse geocoding
The task you're looking for is called reverse geocoding - reverse to ordinary geocoding, which returns the coordinates of an address.
Some ways to do that include the python geocoder module ( https://geocoder.readthedocs.io/api.html#reverse-geocoding ) or the OpenStreetMap Nominatim API https://wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding
Related
I'm using leaflet and esri-leaflet to create a map from a proprietary ArcGIS server. I am trying to get a PDF back from a print server. I have examples using ESRI API 3.x but can't find any using esri-leaflet.
I know the format of and can create the print server request, with the exception of the mapOptions section, where I need extent, spatialReference, and scale. I also know that there is an export requst sent to the map server every time the image changes, and the response from that request contains the information I need. But the request is not generated by my code--it happens as the result of an event.
Esri-leaflet has a event requestsuccess that seems like what I need. If I can intercept all successful requests, I can check to see if it was an export request and save the extent and scale (the extent has the SR embedded). However, I can't find any examples and the documentation gives me little clue as to how to proceed.
I'm not wedded to intercepting the request, but seems the most straightforward way to get what I need. I do know that I could get the bounds from leaflet and convert to extent, but getting the scale is harder (have to get the zoom level and have a mapping for that). So that may be another option.
Esri leaflet includes a handy utility method to convert Leaflet bounds objects to Esri extent object literals
// http://esri.github.io/esri-leaflet/api-reference/util.html
L.esri.Util.boundsToExtent(map.getBounds())
to get the scale, you just need to do a little math on the current zoom level.
// https://gis.stackexchange.com/a/81390/21012
591657550.500000 / Math.pow(2, map.getZoom() - 1)
live demo: http://jsbin.com/ceceqir/edit?html,output
I need to use the Bing Maps API to check if a UK postcode (Not sure how different it is for other countries) is valid.
It seems that I can put any nonsense into the field for postcode and I still get a response.
E.G. http://dev.virtualearth.net/REST/v1/Locations/GB/aregsfdgsdfgsdfgdsf?key=BINGMAPSKEYHERE
Gives a result that has a lat and long of 53.9438323974609, -2.55055809020996 in the "point" field, despite that clearly not being a valid postcode.
Is there a way that I can simply test the validity of a postcode?
If you look at the response object for your request you will see a matchCode value. This indicates if the match it is good or not. In this case it says "UpHierarchy" which indicates that it didn't find the exact result so it when up the address hierarchy until it found a result. The result being returned is for the United Kingdom. Additionally, the results also have an entityType value which tells you the type location that was found. In this case it says CountryRegion. You want an entityType value of "PostalCode". By checking these two values you can determine if the returned result is a postal code or not. More details on the geocode response object is documented here: https://msdn.microsoft.com/en-us/library/ff701725.aspx
One thing I would highlight is that the URL format you are using is a bit of a legacy one and isn't as accurate as passing in a single string query (i.e. &q=YOURQUERY). This is highlighted in the best practices docs. If you are using .NET, I hiehgly recommend using the Bing Maps .NET REST toolkit. It makes things really easy and implements best practices for you.
We have a list of address, And trying to get coordinates of them using server side script.
Due to limitation of google map api(2500 query per 24 hour), We move to bing map REST api.
But when we are calling API its not giving the coordinates, While google map api returning the correct coordinates.
Please tell me what i am doing wrong?
Here is the sample call
http://dev.virtualearth.net/REST/v1/Locations?query=A+Beka+Acadamdy,2303+Maravilla,Lompoc,CA,93436,&incl=queryParse&key=MY_API_KEY
if I replace everything with %20 in address then still its not returning data
http://dev.virtualearth.net/REST/v1/Locations?query=A%20Beka%20Acadamdy%202303%20Maravilla%20Lompoc%20CA%2093436&incl=queryParse&key=MY_API_KEY
Another URL is
http://dev.virtualearth.net/REST/v1/Locations?query=103+Black+Men+of+the+Bay+Area+Community,3403+Malcolm+Avenue,Oakland,CA,94607-1407,&incl=queryParse&key=MY_API_KEY
We also tried with this
https://msdn.microsoft.com/en-us/library/ff817004.aspx#sectionToggle6
But sometimes we don't know the country, That's why its not working correctly.
A couple of things to change. First, drop the name of the location, you only need the street address.
So geocoding "2303 Maravilla, Lompoc, CA, 93436" will work.
Secondly, it looks like you are escaping the query value rather than encoding it. Escaping isn't as good as encoding and will result in some queries failing all together. For example if a query had "first & Main" in it, escaping it would not escape the ampersand which would make everything after it a new URL parameter which would likely either cause an error or mean your query is just for "first". By encoding it the ampersand would be changed to %26. This is documented in the best practices here: https://msdn.microsoft.com/en-us/library/dn894107.aspx
By encoding your query parameter your address will look like this:
"2303%20Maravilla,%20Lompoc,%20CA,%2093436"
Why is it when I request some postcodes from Bing maps I get an incorrect coordinates
http://dev.virtualearth.net/REST/v1/Locations?postalCode=IM1+1LD&countryRegion=GB&o=xml&key=MY_BING_KEY
While when I request it using this I get the correct ones
http://dev.virtualearth.net/REST/v1/Locations?postalCode=IM1&1LD&countryRegion=GB&o=xml&key=MY_BING_KEY
i.e. when I send IM1+1LD as a postalcode incorrect results are returned, while sending IM1&1LD returns the correct results in the response.
The + indicates your are escaping rather than encoding your query. The plus should be %20 instead. Also, in the UK postal codes are a special case. I recommend searching for them using a query search instead like this: http://dev.virtualearth.net/REST/v1/Locations?q=IM1%201LD&o=xml&key=YOUR_KEY
You can find additional tips on use the REST services here: https://blogs.bing.com/maps/2013/02/14/bing-maps-rest-service-tips-tricks
I'd like to work out the distance between two points. No map. No javascript. Just the distance.
I understand Google maps prohibits this and it's against their terms of service. But Bing Maps doesn't have this restriction.
I want to give the points in a general format, i.e "Cambridge" "Church Street, Newcastle"
How would I go about doing it? As basic as possible. It's for a mobile device.
1.) Sign up for a Bing Maps key at http://www.bingmapsportal.com. A key is a alphanumeric string of around 64 characters in length, something like: AtGYpcoIpC5zy0P2k4Bc4839b-=fLgbbnsp72T3ZrM0z7gAaMcjXlZPsKXghW
2.) Then, make a request to the Bing Maps Routes API (http://msdn.microsoft.com/en-us/library/ff701717.aspx) to generate a route between up to 25 waypoints. For the example given, substitute your Bing Maps key into the following URL:
http://dev.virtualearth.net/REST/v1/Routes?wp.1=Cambridge, UK&wp.2=Church St, Newcastle-under-Lyme, UK&key=ENTERYOURBINGMAPSKEYHERE
3.) You'll get a JSON response containing details of the route, turn-by-turn directions etc. as described at: http://msdn.microsoft.com/en-us/library/ff701718.aspx. The total driving distance is given quite near the bottom of the response, called "travelDistance" (in this case,218.703). You can also choose what units this value is returned in by specifying the appropriate distanceUnit parameter when you first request the route.
Is very simple:
http://dev.virtualearth.net/REST/V1/Routes/Walking?wp.0=11025%20NE%208th%20St%20Bellevue%20WA&wp.1=700%20Bellevue%20Way%20NE%20Bellevue WA&key=BingMapsKey
Ref : MSDN