Opacity for MapView and ItemizedOverlay - opacity

Is there a way where I can darken the MapView but not affect the overlay item?
I'd like to make my overlay item really bright as compared to the google map, so that users are more inclined to just tap on the item rather than interacting with the map.
Thanks in advance!

I believe this is hard thing to do, but you can do something else to attract the user (I believe it is better), use AnimationDrawable , you can create multiple images in some sort of way that it can attract the user and use the function addFrame(Drawable d, int duration) to add the images. Good luck

Related

Draw color on country (Mapkit) when it is selected

I want to color the country on selection of the country from a tableView. Can you help me please?
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.

Tiling annotations with Map Kit

Using annotations with Map Kit, you can put pins, or even custom images onto the map. Cool.
However, the data I'm using has millions of locations, spread out across the world. I don't want to dump them all on the map, especially since the user is only looking at a small bit of it. It would kill responsiveness, and probably crash.
Is there a standard technique for putting these pins on to the map only when required? i.e only when they need to be on the map view (and the immediately surrounding area). And removing them when the user has scrolled away. Something similar to UITableView's dequeueReusableCell..?
There's MKMapView's dequeueReusableAnnotationViewWithIdentifier: method which seems to do exactly what you want.
Check out this piece of code: http://www.cocoanetics.com/parts/dtclustermaker/
While it's 100 EUR, it certainly depends on your usage for that amount of money. But it might be worth it. If not, it might get you on your way to find something else via Google searching.

Good strategy for creating bar chart with touch-to-view-value functionality?

I want to create a bar chart diagram. I already have a diagram component, I just need to adapt it to a bar chart. When touching one of the bars, the value shold pop up in small view.
As I can see there are several different strategies that can be applied here. What I want to know is which strategy should I use? Any of these or perhaps there are other better ideas?:
Bar is a UIButton.
Bar is a touch enabled UIImage.
Bar is a UIView.
Bar is just painted graphics and I have to transcode the touched coordinates and make some calculations in order to know what bar was touched. I don't don't believe in this strategy but perhaps there are reasons to rethink this that you can provide for me...
I assume that a UILable is the way to present the data associated with the bar?
Thanks in advance for your advice!
In my humble opinion, and having written many bar charts (and other charts)... #4 is actually the correct choice for performance and my personal preference. Creating the virtual graph in memory to map touches to bars is not difficult at all, as you are simply storing rectangles in arrays and checking to see if points are inside that rect.
CGRectContainsPoint(CGRect, CGPoint);
Now, having said that, if you want to introduce animations in to your chart, which is pretty cool stuff... then I could create a UIView composed of several UIViews (one for each bar, or bar segment), this way you can animate each bar individually without writing your own animation loop.
just my two cents.
my thoughts are that #2 and #3 are kind of the same since you'd display an image using a UIImageView. UIButton is a pretty thin layer on UIView that makes the event handling easy, but it might do things visually you don't want (or maybe you do?). Either way, it's so easy to try these variations I'd just play with it. I can't see a specific reason for #4 unless your overall strategy drives you in this direction, like maybe you start doing some drawing that is rich/complex enough that you have too many views being created.
AFA the popup display, it really depends what you mean by "pop up". Like once it pops up, do you need a way to dismiss that popup?
Have you checked out Core Plot? It is an active and powerful library that is pretty flexible and should meet all your needs.

Show annotation on MKMapView based on user location

I've problem with Objective C at the moment with developing something special.
So - after the MKMapView is initialized and the users position is shown, I would like to implement a method to show annotations which are next to users position. I've stored all necessary points in an SQLite database in a special table. I've two fields - namely lonand lat- I think it's clear what is meant by that.
Has anybody an idea how to show JUST those annotations which are visible at the screen to be as performant as possible. After the user scrolls the map - it should call the method again to look up in database wether there are also other points which need to be shown...
Thank you very much in advance for your help,
kind regards,
Dominik
You will need to do a few things.
1) Get the center of your map - use the centerCoordinate property of your MKMapView
2) Ask your database for all items within a certain distance from the center of the map.
3) Display them
It's (2) that's the tricky one - you need a method that will return all items near to the lat lng you have.
This link has a handy implementation of how to do that :)
Hope that helps.
A couple of points:
If you're using iOS4, the mapview behaviour has changed so that it automatically saves memory by only creating the annotations which are in the visible view.
Secondly, in the same way that you can create a tableview with thousands of cells and still have it scroll smoothly, the annotations offscreen don't affect the performance that much. You should be keeping your annotations very small so they don't consume much memory. The annotation views are the ones that take up the memory.
Your problem is going to come when the user zooms out and there are too many annotation views visible at the same time. When you're zoomed in, you don't need to worry too much about off-screen annotations.

2 buttons having the same functionality in iphone application

I am creating an application with call functionality, I want to have the phone image on the right hand side and the name of the contact on the left hand side. Currently this has been implemented by placing the 2 buttons side by side, hence if the user clicks on any of the buttons, the same functionality (calling the contact) happens.
Is this allowed according to Apple HIG? Please let me know.
Thank You,
Ashvin
I don't think anything in the HIG specifically disallows this, but it seems like a bad idea, for a couple of reasons:
If there are two buttons side-by-side, users will assume the buttons do different things, and will be confused when they don't.
It wastes screen real-estate that could probably be put to better use.
From your description it is hard to tell exactly what this looks like, but it sounds like something that needs to be re-designed.
Overlapping buttons?
It might not give you an intuitive UI, as the content of the overlapped button might get truncated by the overlapping button.
As Kristopher has explained, it will result in a bad user experience.
It is possible, that your app might get rejected because of the truncations as the user will not be readily able to perceive the content.
If look of the button is what you are concerned about, then you can just set one image (whether odd shaped or not) to one button, as long as the user is able to perceive that it is a button.
In the odd shaped image, you should also ensure that the functionality does not get triggered when the user touches the transparent area of the image, otherwise it might confuse the user.
Hope these points help!
Is there any mention about overlapping the buttons? Suppose for better design/look and feel, I have to place two buttons which partially overlaps each other, is it disallowed? Still the screen looks good and there will not be any confusion about the buttons. But only point is they are two different buttons, which assumes same functionality and has overlapped.
Adding some more information on the about query.
The buttons are overlapping as one is just a graphics and another is a rounded rectangle button whose Title changes dynamically.
If they can not be overlapped, can we have an odd shape button on the screen as long as user feels that they are buttons?
Thanks.

Categories