开发者

Forward geocoding in iphone

开发者 https://www.devze.com 2023-02-22 16:15 出处:网络
I have bunch of addresses coming from server.I want to get the lat long ofall theaddresses & want to store them for further use.

I have bunch of addresses coming from server.I want to get the lat long of all the addresses & want to store them for further use. and I want to display the selected addresses (according to distance,say within 1 km, from a specific location)on the map. I got a good example here:http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google

but this one only deals with a single address开发者_如何学JAVA(or query) not multiple.


I like the Open Streetmap API a lot. I think it's simpler and more philosophically agreeable than the Google api.

http://nominatim.openstreetmap.org/search?format=json&q=disneyland

Put whatever address value you like in the "q=" parameter.

So then: you loop through the addresses the server returned, banging nominatim for lat/long values, you store those (probably an an NSMutableDictionary), and you're off to the races.


Loop through the array of addresses and use that code each time. Put it on a background thread so that you don't block the UI, then either call back to your main thread each time it finds one, or send the main thread a dictionary when it's finished. Pause the query by 2 seconds after each query so that Google doesn't block you for hammering their server.

Use distanceFromLocation: to find your distances.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号