Re: [route-me] Marker balloons ??

276 views
Skip to first unread message
Message has been deleted

Jose Manuel Simón Hernández

unread,
May 9, 2011, 5:24:01 PM5/9/11
to route-...@googlegroups.com
I did it a few weeks ago.

There is a project in github about it, but it wasn't useful to me, so
i created it with in my own way.

If you ate interested, i can post my code.

El 09/05/2011, a las 23:17, Neil Sonaron <neil.s...@gmail.com> escribió:

> Hi,
> is there any feature to show balloons with text when a marker is
> clicked??
>
> Something like: http://images.apple.com/iphone/features/images/maps-directions-20100607.jpg
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups "route-me" group.
> To post to this group, send email to route-...@googlegroups.com.
> To unsubscribe from this group, send email to route-me-map...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.
>

Philip Brechler

unread,
May 9, 2011, 5:55:32 PM5/9/11
to route-...@googlegroups.com

Am 09.05.2011 um 23:24 schrieb Jose Manuel Simón Hernández:

> If you ate interested, i can post my code.

Yes, please!

Simon

unread,
May 10, 2011, 5:28:27 AM5/10/11
to route-me
#define CENTER_IMAGE_WIDTH 31
#define CALLOUT_HEIGHT 45
#define MIN_LEFT_IMAGE_WIDTH 16
#define MIN_RIGHT_IMAGE_WIDTH 16
#define LABEL_HEIGHT 48
#define LABEL_FONT_SIZE 15
#define ANCHOR_Y 60


-(void) addMarkerAt:(CLLocationCoordinate2D) markerPosition withTitle:
(NSString *)titulo withStyle:(NSString *)style
{


CGSize size = [titulo sizeWithFont:[UIFont
boldSystemFontOfSize:LABEL_FONT_SIZE]];
float sizes = size.width;

int left_width2 = ((int)(sizes + CENTER_IMAGE_WIDTH)/2)-5;
int right_width2 = (int)(sizes + CENTER_IMAGE_WIDTH)/2;

label=[[UIView alloc]initWithFrame:CGRectMake(((-left_width2*2+21)/
2)-18, 19 - ANCHOR_Y,0 , 0)];

label.backgroundColor = [UIColor clearColor];
label.userInteractionEnabled=YES;


CALLOUT_LEFT_IMAGE = [[[UIImage imageNamed:@"callout_left.png"]
stretchableImageWithLeftCapWidth:15 topCapHeight:0] retain];
CALLOUT_CENTER_IMAGE = [[[UIImage
imageNamed:@"callout_center.png"]stretchableImageWithLeftCapWidth:30
topCapHeight:0]retain];
CALLOUT_RIGHT_IMAGE = [[[UIImage imageNamed:@"callout_right.png"]
stretchableImageWithLeftCapWidth:1 topCapHeight:0]retain];


calloutCenter = [[UIImageView alloc]
initWithFrame:CGRectMake(left_width2-5+5,0, right_width2+5+5,
CALLOUT_HEIGHT)];
calloutCenter.image = CALLOUT_CENTER_IMAGE;
[label addSubview:calloutCenter];
[calloutCenter release];


calloutLeft = [[UIImageView alloc] initWithFrame:CGRectMake(round(0),
round(0), left_width2-5+5, round(CALLOUT_HEIGHT))];
calloutLeft.image = CALLOUT_LEFT_IMAGE;
[label addSubview:calloutLeft];
[calloutLeft release];

calloutRight = [[UIImageView alloc]
initWithFrame:CGRectMake(left_width2*2+5+10, round(0), 16,
round(CALLOUT_HEIGHT))];
calloutRight.image = CALLOUT_RIGHT_IMAGE;
[label addSubview:calloutRight];
[calloutRight release];


calloutLabel = [[UILabel alloc]
initWithFrame:CGRectMake(MIN_LEFT_IMAGE_WIDTH-3, -8.5, sizes,
LABEL_HEIGHT)];
calloutLabel.font = [UIFont boldSystemFontOfSize:LABEL_FONT_SIZE];
calloutLabel.text=titulo;
calloutLabel.textColor = [UIColor whiteColor];
calloutLabel.backgroundColor = [UIColor clearColor];
[label addSubview:calloutLabel];
[calloutLabel release];


UIButton *buttongo= [UIButton
buttonWithType:UIButtonTypeDetailDisclosure];
buttongo.frame=CGRectMake(left_width2*2-3, 4, 25, 25);
buttongo.multipleTouchEnabled=YES;
buttongo.userInteractionEnabled=YES;
buttongo.enabled=YES;
[label addSubview:buttongo];


RMMarker *newMarker = [[RMMarker alloc] initWithUIImage:[UIImage
imageNamed:style] anchorPoint:CGPointMake(0, 1)];
[newMarker setLabel:label];
[newMarker hideLabel];
[mapView.contents.markerManager addMarker:newMarker
AtLatLong:markerPosition];
if (style==@"userGoogle.png") {
userMarker=newMarker;
}

NSNumber* clickCounter = [[NSNumber numberWithInt: 0] autorelease];
newMarker.data = clickCounter;

[markersToErase addObject:newMarker];


[newMarker release];
[label release];
}



- (void) tapOnMarker: (RMMarker*) marker onMap: (RMMapView*) map
{
NSInteger clickCounter = [((NSNumber*) marker.data) intValue] + 1;
NSInteger clickCounterShowed = [((NSNumber*) markerLabelShowed.data)
intValue]+1;
if (markerLabelShowed!=NULL){
[markerLabelShowed hideLabel];
markerLabelShowed.data = [NSNumber numberWithInt:
clickCounterShowed];
}
if (clickCounter%2==1) {
[marker showLabel];
markerLabelShowed=marker;
}else {
[marker hideLabel];
markerLabelShowed=NULL;
}

marker.data = [NSNumber numberWithInt: clickCounter];


}



I am sure it can be better coded, but here is done in my way.

You need the 3 images: http://www.megaupload.com/?d=41WAJ2UA


I hope, you can understand how i create the balloons. If you have any
problem, ask me.


Message has been deleted

Chris James

unread,
May 10, 2011, 2:26:34 PM5/10/11
to route-...@googlegroups.com
Simon,

Thanks for the code! So far it looks great, I am having an issue with
the Button in the view though

I modified it your code a little and added a target to the button
buttongo.tag = 23;
[buttongo addTarget:self action:@selector(buttonEvent:)
forControlEvents:UIControlEventTouchUpInside];
[label addSubview:buttongo];

- (void)buttonEvent:(id)sender
{
NSInteger tid = ((UIControl*)sender).tag;
NSLog(@"The URL VALUE IS: %@",tid);
}


however when i press the button, nothing happens, any ideas?

Vladimir Vyskocil

unread,
May 10, 2011, 3:11:13 PM5/10/11
to route-...@googlegroups.com

> however when i press the button, nothing happens, any ideas?

As the markers are based on CALayer instead of UIView (for performance reason) touch events are not propagated to the controls like your button...

Vlad.

Jose Manuel Simón Hernández

unread,
May 10, 2011, 3:20:21 PM5/10/11
to route-...@googlegroups.com
There is a function for that. I am not at home, i will answer you in
about an hour

El 10/05/2011, a las 21:11, Vladimir Vyskocil
<vladimir...@gmail.com> escribió:

>
>> however when i press the button, nothing happens, any ideas?
>
> As the markers are based on CALayer instead of UIView (for performance reason) touch events are not propagated to the controls like your button...
>
> Vlad.
>

Simon

unread,
May 11, 2011, 6:38:34 AM5/11/11
to route-me
(void)pushMapAnnotationDetailedViewControllerDelegate:(id) sender
(corresponds to tap on annotation disclosure button)
and:
- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*)
map (corresponds to tap on annotation itself)
methods to handle taps on annotation view. In your particular case –
replace:
(void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map
onLayer:(CALayer*) layer
with:
- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*)
map

On May 10, 9:20 pm, Jose Manuel Simón Hernández <saimon...@gmail.com>
wrote:
> There is a function for that. I am not at home, i will answer you in
> about an hour
>
> El 10/05/2011, a las 21:11, Vladimir Vyskocil
> <vladimir.vysko...@gmail.com> escribió:

saini

unread,
May 18, 2011, 5:06:39 AM5/18/11
to route-me
Hi simon,

Thanks for the code! I am having an issue with
the Button.how you doing the button action by this method:
(void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map
onLayer:(CALayer*) layer

plz help me.

Simon

unread,
May 20, 2011, 11:31:38 AM5/20/11
to route-me
Hi saini. Sorry, i have been out these days.

Are you using CloudMade?

I am having some problems with the last version.

http://support.cloudmade.com/forums/iphone-sdk/posts/1824/show

Arun Saini

unread,
May 21, 2011, 12:48:57 AM5/21/11
to route-...@googlegroups.com
Hi simon,
yeh ,I am using CloudMade map .
and i have the same problem, button press not  recognized.
If you have any solution of that ,Please provide me.
--
Thanks & Best Regards,
-------------------------
Arun  Kumar Saini(8909630609)
Iphone Developer ,
Evon Technologies , Dehradun
Web:www.evontech.com


Arun Saini

unread,
May 30, 2011, 1:35:56 AM5/30/11
to route-...@googlegroups.com
Hi simon

when you finish our holidays?
Please let me know .I need your help regarding :how are  you doing the button action on marker ballons?

Thanks,

On Fri, May 20, 2011 at 9:01 PM, Simon <saim...@gmail.com> wrote:
For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.

Simon

unread,
May 31, 2011, 4:30:57 PM5/31/11
to route-me
I have no solution yet.

Right now, i just make tap inside the "markerballon", and not inside
the disclosure button.

That is the only way to make it, right now.

I haven't had any answer from cloudmade yet. You can try to send them
an e-mail.

If you have any new, please post it here.

Thanks!!!
> *Thanks & Best Regards,
> -------------------------
> Arun  Kumar Saini(8909630609)
> **** Iphone Developer ,
> **Evon Technologies , Dehradun
> **Web:www.evontech.com*
Reply all
Reply to author
Forward
0 new messages