2

I am developing a game in which the user has to select a country on a world map.

I was thus wondering:

  1. what's the best approach to show an interactive map? I found this framework/component on the Web http://mousebird.github.com/WhirlyGlobe/ but I am also evaluating MapKit, MapBox and Google Maps frameworks. In your opinion and from your own experience, what would be the best choice?

  2. Given some GPS coordinates, how can I retrieve the country name? (I'm interested only in the country name, nothing more)

  3. Is there any sample code or tutorial in which such an application is implemented?

Thanks!

pAkY88
  • 6,262
  • 11
  • 46
  • 58

2 Answers2

3

In Google Map SDK for iOS You have to try with this Delegate Method.

It is giving you coordinate where user tapped.

- (void)mapView:(GMSMapView *)mapView
didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
    NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);
}

With this particular coordinates you can find country.

I think you have to check this . It will help you.

iDev
  • 1,042
  • 13
  • 19
  • Thanks! Seems to be pretty simple :-) – pAkY88 Apr 05 '13 at 13:31
  • This merely tells you the coordinate. You still need to determine the polygon that contains the point and map that to a country name. – incanus Apr 05 '13 at 17:33
  • @incanus than you for the tip! Actually, retrieving the country name from GPS coordinates is quite simple. You can do so by using the reverse geocoder of MapKit or GoogleMaps API. – pAkY88 Apr 05 '13 at 18:46
0

You should also check out MapBox. The iOS SDK supports full, configurable interactivity. There is an example app for converting a tap into the name/flag of the country tapped.

https://github.com/mapbox/mapbox-ios-example

incanus
  • 5,100
  • 1
  • 13
  • 20
  • Thank you for the tip! If I understood well, the example you linked takes afvantage of the offline version of MapBox APIs, so it does not require to subscribe a paid plan. Right? – pAkY88 Apr 05 '13 at 08:43
  • This can work online or offline. The example app shows an online source, which requires a plan (which, depending on usage, could qualify for free) or a tile server that supports UTFGrid interactivity. Either way, the map goes into MBTiles format, which can be uploaded to MapBox hosting or using directly on device. Here is a good guide to creating a custom map with something like country name embedded in the interactivity data: http://mapbox.com/tilemill/docs/crashcourse/tooltips/ – incanus Apr 05 '13 at 17:35
  • once again, thank you for this tip! I had a look at the MapKit iOS example and I noticed that the MBTiles database is very big (about 20MB). This means that it's not practical to use that for a iOS app which should be published on the App Store. So my question is: supposing that I decide to use MapBox, is it possible to develop an application with the above-mentioned requirements which works completely offline? – pAkY88 Apr 05 '13 at 18:55
  • Well, the over-the-air limit is 50MB, so that's not a ridiculous size, but you are going to have to either pre-bundle at a certain size or download an MBTiles post-launch in order to use maps over a certain size offline. There is only so much you can squash it down. – incanus May 06 '13 at 18:08