Skip to content

Instantly share code, notes, and snippets.

@pcperini
Last active August 29, 2015 14:02
Show Gist options
  • Save pcperini/3a433523ce8e67c25444 to your computer and use it in GitHub Desktop.
Save pcperini/3a433523ce8e67c25444 to your computer and use it in GitHub Desktop.
WorldPin Socket Events
- (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