问题
is there any way to determine which type of area you are in from a MKMapView? I.e. if the centre of the map is in the ocean we can tell the user: the centre of the map is above the ocean, or if the map is centred above a green area: the centre of the map is above parkland...
The only way I can think of to do this is to create a screenshot of the visible screen and analyse the colour of each bit by using some method such as this: iOS -- detect the color of a pixel?
However I would be interested to know if there is an easier way that anyone can think of!
EDIT
To make it more clear what I'm looking for, I'm basically looking for a way to turn a section of a map into a top down level for a game, with different areas determined by the areas of the map...
回答1:
A CLPlacemark
has a couple of properties: inlandWater
and ocean
which tell you when the placemark is in water. I think you can get a placemark from the geocoder.
It also has areasOfInterest
which will give you parks and landmarks.
回答2:
there is no foolproof way BUT CLGeocoder
can reverse geocode a coordinate to an address and that would give you stuff like:
0/0 = ...., ocean 51/10 = ..., germany -90/10 = ..... , united states
and so on
来源:https://stackoverflow.com/questions/15463095/find-out-which-type-of-area-you-are-in-from-mkmapview