This file contains hidden or 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
// get Context for a point | |
SGContextQuery *query = [SGContextQuery queryWithPoint:[SGPoint pointWithLat:37.772445 lon:-122.405913]]; | |
[client getContextForQuery:query | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got Context! | |
// to create an SGContext object... | |
SGContext *context = [SGContext contextWithDictionary:response]; |
This file contains hidden or 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
// get all your layers | |
[client getLayersWithCursor:nil // for pagination | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got layers! | |
// To create an array of SGLayer objects... | |
NSArray *layers = [NSArray arrayWithSGCollection:SGCollectionTypeLayers]; | |
} failureBlock:^(NSError *error) { | |
// handle failure |
This file contains hidden or 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
// get info about a specific layer | |
[client getLayer:@"com.simplegeo.example" | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got a layer! | |
// To create an SGLayer object... | |
SGLayer *layer = [SGLayer layerWithDictionary:response]; | |
} failureBlock:^(NSError *error) { | |
// handle failure |
This file contains hidden or 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
// delete a layer | |
[client deleteLayer:@"com.simplegeo.example" | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// deletion confirmed | |
} failureBlock:^(NSError *error) { | |
// deletion failed | |
}]]; |
This file contains hidden or 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
// add or update a layer | |
SGLayer *layer = [SGLayer layerWithName:@"com.simplegeo.example" | |
title:@"Example Layer" | |
description:@"Created from SimpleGeo.framework" | |
callbackURLs:nil]]; // optional list of callback URLs | |
[client addOrUpdateLayer:layer | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { |
This file contains hidden or 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
// get a specific record | |
[client getRecord:@"recordID" | |
inLayer:@"com.simplegeo.example" | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got a record! | |
// to create an SGStoredRecord object... | |
SGStoredRecord *record = [SGStoredRecord recordWithGeoJSON:response]; | |
} failureBlock:^(NSError *error) { |
This file contains hidden or 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
// get a record's location history | |
[client getHistoryForRecord:@"recordID" | |
inLayer:@"com.simplegeo.example" | |
limit:nil // optional limit | |
cursor:nil // for pagination | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got location history! | |
// to create an array of SGPoint objects... |
This file contains hidden or 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
// find ten records in a given area | |
SGEnvelope *envelope = [SGEnvelope envelopeWithNorth:40.613952 | |
west:-105.90271 | |
south:39.078908 | |
east:-103.513184]; | |
SGStorageQuery *query = [SGStorageQuery queryWithEnvelope:envelope | |
layer:@"com.simplegeo.example"]; |
This file contains hidden or 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
// find the ten nearest records, created within the past 24 hours, within two kilometers of an address | |
SGStorageQuery *query = [SGStorageQuery queryWithAddress:@"41 Decatur St, San Francisco, CA" | |
layer:@"com.simplegeo.example"]; | |
[query setRadius:2.0]; | |
[query setLimit:10]; | |
[query setDateRangeFrom:[NSDate dateWithTimeIntervalSinceNow:-86400] | |
to:[NSDate date]]; |
This file contains hidden or 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
// get records near a point | |
SGStorageQuery *query = [SGStorageQuery queryWithPoint:[SGPoint pointWithLat:37.772445 lon:-122.405913] | |
layer:@"com.simplegeo.example"]; | |
[client getRecordsForQuery:query | |
callback:[SGCallback callbackWithSuccessBlock: | |
^(id response) { | |
// you've got records! | |
// to create an array of SGStoredRecord objects... |