简体   繁体   中英

iOS maps and google maps SDK - working with coordinates

I am using the Google Maps SDK but I this question i think will be just as relevant for the native maps on iOS. I want to Select a random location on Google Street View , I could create random coordinates and then ask if a Street View image exist at that location, if not create a new random coordinate. But this would be quite 'exhaustive' as it would end up asking for a lot of street view photos were there exist none.

Is there a better way of hard coding the coordinates? if so - is there somewhere I could get such a list over coordinates around the world?. One of the functions I need is to limit the random photos by country, so that it for example only show photos from the UK. is this possible with random coordinates? or do I need hard coded coordinates that is in the UK?

I would need well over 100.000 hard coded coordinates - so doing this myself manually is not an option, unless there is a way of generating them automatically thought.

As you have said, generating random coordinates and checking for streetview availability will be inefficient since many countries do not have streetview coverage.

I would recommend the below approach:

1, Get the list of countries with full streetview coverage as given in the list.

2, Choose the set of countries you would like to cover in your app and for those countries create a list of bounding boxes. For example , if you use the geocoding api with the address as a country , then the response will have coordinates of the bounding box that will approximately enclose the country.

3, In your app, retain the list of countries and bounding boxes. Now randomly pick a country from the list and then build a random coordinate that lies within the bounding box for that country. That is

SW.latitude <= randomlatitude <= NE.latitude 

SW. longitude <= randomlongitude <= NE.longitude

These random coordinates will mostly have streetview coverage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM