Last active
August 29, 2015 14:02
-
-
Save pcperini/3a433523ce8e67c25444 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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[SIOSocket socketWithHost: @"http://yourHost:3000" response: ^(SIOSocket *socket) | |
{ | |
self.socket = socket; | |
}]; | |
} | |
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation | |
{ | |
// Zoom to user location | |
MKMapCamera *camera = [mapView.camera copy]; | |
camera.altitude = 1; // Zoom in | |
camera.centerCoordinate = userLocation.coordinate; | |
mapView.camera = camera; | |
// Broadcast new location | |
if (self.socketIsConnected) | |
{ | |
[self.socket emit: @"location" args: @[ | |
[NSString stringWithFormat: @"%f,%f", userLocation.coordinate.latitude, userLocation.coordinate.longitude] | |
]]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment