Last active
August 29, 2015 14:02
-
-
Save pcperini/5d54c823f835f7dd856b to your computer and use it in GitHub Desktop.
WorldPin Socket Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[self.socket on: @"update" callback: ^(SIOParameterArray *args) | |
{ | |
// pinData == @"pinID:lat,long" | |
// self.pins == @{@"pinID": <WPAnnotation @ (lat, long)>} | |
NSString *pinData = [args firstObject]; | |
NSArray *dataPieces = [pinData componentsSeparatedByString: @":"]; | |
NSString *pinID = [dataPieces firstObject]; | |
NSString *pinLocationString = [dataPieces lastObject]; | |
WPAnnotation *pin = [[WPAnnotation alloc] initWithCoordinateString: pinLocationString]; | |
if ([[self.pins allKeys] containsObject: pinID]) | |
{ | |
CLLocationCoordinate2D newCoordinate = pin.coordinate; | |
pin = self.pins[pinID]; | |
pin.coordinate = newCoordinate; | |
[self.mapView removeAnnotation: pin]; | |
} | |
self.pins[pinID] = pin; | |
[self.mapView addAnnotation: pin]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment