I want to color the country on selection of the country from a tableView. Can you help me please?
-
I don't think `MapKit` has any in-built support for it, nor can you make changes to it. At the most, you could probably show images on top of the map to give the illusion of a selection but I'm still not sure of it. The best way would be to use pins. – tipycalFlow Feb 03 '12 at 11:08
-
can anyone suggest me any api to get boundary of the country??? – Anil Kothari Feb 03 '12 at 11:14
1 Answers
Considering your case, let me give you a heads up that this would require edge detection (so if you haven't done that before, it will take a LONG time), though not lots of it and the following is just one way of approaching this problem:
1) Take out an image context from the map you have.
2) Apply relevant edge detection algorithms in the area you want and use a bright color to differentiate. Note that this way, the inside would not be colored and I can't tell you for sure if that's possible or not.
3) Add that context as a subView on top of the map.
Also take a look at the Quartz 2D programming guide for more tips.
I would suggest something different, though. Keep pre-stored images for all the possibilities and just put a UIImageView
with that as its image in front of the map - this will save you a lot of headache.

- 7,594
- 4
- 34
- 45
-
Take a look [here](http://dasl.mem.drexel.edu/~noahKuntz/openCVTut5.html) and [here](http://stackoverflow.com/questions/5037502/edge-detection-of-image-in-iphone-using-image-magick) – tipycalFlow Feb 06 '12 at 09:28
-
Due to shortage of time Now I have decided to take a few boundary coordinates of the country and then put an MKpolygenView over the map. – Anil Kothari Feb 07 '12 at 06:35
-
Find `MapKit` [overlays here](http://disanji.net/iOS_Doc/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html) – tipycalFlow Feb 07 '12 at 06:52
-
@AnilKothari: Do you know any way to get boundary coordinates of a country? – vietstone Nov 01 '12 at 04:08
-
-
Why would you need edge detection? You don't have to get the shapes of the countries from the maps: Those are known and shapefiles for the world can be found. you 'only' have to put the right overlay over the map. – PanMan Feb 25 '14 at 12:38
-
I believe @PanMan's solution is easier, simply overlay a country's image over the map using the lat-long and current map zoom level. That would require mapping every country's lat-long bounds with current location being shown on map – tipycalFlow Feb 27 '14 at 13:15