Skip to content

[TIMOB-1242] Support to draggable annotations (Drag & Drop) #1670

Merged
merged 5 commits into from Apr 23, 2012

4 participants

@rafaelks

This commit, makes support to make draggable annotations.
When you create an annotation, you just have to set the "draggable" property (boolean) and it will works.

When you drag and drop the annotation, will fire an event called pinchangedragstate. This event will return the new state and the old state from the annotation.

The coordinates from the annotation is changed automatically.

TIMOB: https://jira.appcelerator.org/browse/TIMOB-1242

@marshall

@rafaelks Thanks for updating this :) We will get back to reviewing ASAP

@marshall

This is a reopen of #1193, Signed CLA is in place

@vishalduggal vishalduggal and 2 others commented on an outdated diff Mar 15, 2012
iphone/Classes/TiMapView.m
+}
+
+- (NSString *)annotationViewDragStateToString:(MKAnnotationViewDragState)state
+{
+ switch(state)
+ {
+ case MKAnnotationViewDragStateStarting:
+ return @"starting";
+ case MKAnnotationViewDragStateDragging:
+ return @"dragging";
+ case MKAnnotationViewDragStateCanceling:
+ return @"canceling";
+ case MKAnnotationViewDragStateEnding:
+ return @"ending";
+ }
+ return @"none";
@vishalduggal
vishalduggal added a note Mar 15, 2012

All these string constants must be defined as constants in the MapModule. Use the MAKE_SYSTEM_STR macro.

@rafaelks
rafaelks added a note Mar 23, 2012

I don't understood how to do it. I need to define the strings (@"starting", etc) or the constants (MKAnnotationViewDragStateStarting, etc..) ?

And when I define the constants, how can I use on this source?

@mattapperson
mattapperson added a note Mar 23, 2012

MAKE_SYSTEM_PROP(AnnotationDragStarting, MKAnnotationViewDragStateStarting);
placed outside of any method would be an example

@rafaelks
rafaelks added a note Mar 23, 2012

Understood. So, the strings (@"starting", etc) will continue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@vishalduggal

Code reviewed. One small fix required otherwise looks good.

@marshall

@rafaelks FYI looks like we just need one minor fix and we can continue to process your PR :)

@rafaelks
@rafaelks

I really need help to use the MapModule. How I have to do, exactly?

@vishalduggal

MapModule.h (Declare Properties)
@property(nonatomic,readonly) NSNumber *ANNOTATION_DRAG_STATE_NONE;
@property(nonatomic,readonly) NSNumber *ANNOTATION_DRAG_STATE_START;
@property(nonatomic,readonly) NSNumber *ANNOTATION_DRAG_STATE_DRAG;
@property(nonatomic,readonly) NSNumber *ANNOTATION_DRAG_STATE_CANCEL;
@property(nonatomic,readonly) NSNumber *ANNOTATION_DRAG_STATE_END;

MapModule.m (Define Properties)
MAKE_SYSTEM_PROP(ANNOTATION_DRAG_STATE_NONE,MKAnnotationViewDragStateNone);
MAKE_SYSTEM_PROP(ANNOTATION_DRAG_STATE_START,MKAnnotationViewDragStateStarting);
MAKE_SYSTEM_PROP(ANNOTATION_DRAG_STATE_DRAG,MKAnnotationViewDragStateDragging);
MAKE_SYSTEM_PROP(ANNOTATION_DRAG_STATE_CANCEL,MKAnnotationViewDragStateCanceling);
MAKE_SYSTEM_PROP(ANNOTATION_DRAG_STATE_END,MKAnnotationViewDragStateEnding);

TiMapView.m
Remove annotationViewDragStateToString method.
Modify event dictionary as follows
NSDictionary * event = [NSDictionary dictionaryWithObjectsAndKeys:
viewProxy,@"annotation",
ourProxy,@"map",
title,@"title",
indexNumber,@"index",
NUMINT(newState),@"newState",
NUMINT(oldState),@"oldState",
nil];

@rafaelks

OK, I declared and use the constants.
Thanks @vishalduggal.

@vishalduggal

Code Reviewed. ACCEPTED

@vishalduggal

Functional Passed. Tested on IOS Sim (4.3, 5.0, 5.1) and ipod 3rd gen (4.0.2). ACCEPTED

@vishalduggal vishalduggal merged commit 162d608 into appcelerator:master Apr 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.