4

I use Apple's CLGeocoder and when I retrieve placemark's address dictionary it is as expected for locations inside China, but empty for requests in other countries.

Isn't CLGeocoder supposed to work worldwide?

Here is what I get when I print addressDictionary:

[FormattedAddressLines: (
    ""
), CountryCode: ]

I tried to put my device in English as I know it change the content of addressDictionary, but without success.

Dennis
  • 2,119
  • 20
  • 29
PeYoTlL
  • 3,144
  • 2
  • 17
  • 18
  • 1
    OK, after trying on Apple Maps application, it's the same, coannot get the address of a dropped pin... The source of the problem seems to be the use of 高德地图 (amap) by Apple in China for Maps – PeYoTlL Apr 15 '15 at 06:25
  • Interesting. How does it decide which API to use? Your own location? Your IP? What happens when you turn on VPN? – Thilo Apr 15 '15 at 06:34
  • I tried with VPN, by disabling location and cellular network, changing phone country but it still use 高德, It should use my last GPS coordinates or something else... I think if I do a factory reset and connect directly through a VPN using WiFi, it should be OK :D – PeYoTlL Apr 15 '15 at 06:42
  • 1
    Just putting the phone in airplane mode + WiFI + VPN and restarting it seems to be enough – PeYoTlL Apr 15 '15 at 06:47

2 Answers2

1

After performing some tests, there are two types of settings for the Geocoder service:

  1. Autonavi (amap.com) for user located in Mainland China
  2. Apple Map for the rest of the world (I haven't tried all the countries)

Like you explained the Autonavi service can't use Geocode for locations outside of Mainland China. You can see the two services by printing out the [CLPlacemark]

We can see the different version_domain:

For China:

"version_domain" = (
                autonavi,
                revgeo,
                cn );

Outside of China (Japan):

"version_domain" = (
                apple,
                revgeo,
                JP );

What to do?

Well, even if sometimes the Geocode might work we can't rely on it. We can't rely on Google either so you may have a look at Nokia Here Map. Otherwise you should change the way your app interacts with Chinese users. Perhaps you can publish a specific app only for the Chinese AppStore.

How to change the Geocoder during development?

In my case as soon as I am connected to a Chinese phone carrier (e.g.: China Mobile) the map will switch to Autonavi. Using a Wifi will also produce the same effect.

What I do is I use the flight mode, then I connect to a VPN outside of China and finally I kill and restart my app.

On the Simulator you need to simulate the location and then using a VPN on your Mac.

Conclusion

China doesn't make things easy for developers but I believe there is always a solution.

Romain
  • 649
  • 1
  • 5
  • 18
0

Apple use 高德地图 for users located in China and don't allow access to Maps related data for foreign locations. So I think there is no way of using CLGeocoder inside China for a location outside China. I think I will use Google API in that case.

PeYoTlL
  • 3,144
  • 2
  • 17
  • 18