开发者

MKMapView framwork hasn't the relief google-map type in MKMapType declaration, but it works [closed]

开发者 https://www.devze.com 2023-03-17 03:26 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about programming within the scope defined in the help center.

Closed 5 years ago.

Improve this question

i was trying to use a MKMapView, and i wanted to show/change the kind of map which google offers. We all know that on web sites we can use normal-roads type, hybrid type, satellite/photo type and, more recently, also the relief type.

this last is the one i'd like to use. I had no problem to insert it in a UIWebView + HTML + standard google API, but for many reasons now i'd prefer use it with a MKMapView. But... surprise:

"it seems" we couldn't use tat type of map...

reading in Apple MKMapView Class Reference:

MKMapType

The type of map to display.

enum {
   开发者_如何学PythonMKMapTypeStandard,
   MKMapTypeSatellite,
   MKMapTypeHybrid
};

where 0 is for MKMapTypeStandard

1 is MKMapTypeSatellite

and of course 2 is MKMapTypeHybrid...

so we are officially allowed to use just those 3 kind of maps, not the relief type, it seems it doesen't exist at all in the apple framwork...

but i'm curious and so i tried this:

myMKMapView.mapType = 3; // a number not officially declared

and it works perfectly, the apple framweork asks to google the right type of map and then it shows it in my view, both in simulator and iPhone device.

so, that's my question:

Do you think I could use it anyway even if it's not "officially" declared in apple documents? Would Apple reject my app to use it's framework this way?

thanks in advance,

luca


I'm sure Apple would reject your app if they knew you were doing it as they are quite clear that you can only use documented features. I know they have tools which detect calls to undocumented methods and use of private frameworks but whether that extends to checking the value of a property when it's set, I'm not sure.

What I am sure though is that this creates fragile code. If Google introduces other map types and Apple decides to support them all in a future SDK update there's no guarantee that the relief type will remain as 3. Also what if Apple adds a check to this property so that in a future iOS release setting it to 3 will throw an exception? Your app will break for anyone that upgrades their OS and you will be forced to use another map type which may upset your users as the functionality is changing. That's just two examples of changes out of your control that could break this for your users.

In summary, could you use this: Yes, but Apple may reject your app and the only way to find out if they will or not is to do it. You'll also have to stay on your toes to ensure future iOS updates don't break your code.

0

精彩评论

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