welcome to linkAR technical documentation

next previous

Adding POIS

Adding a POI to the browser requeres using the following data class:

Poi: Represents a POI. The object has the POI's GPS coordinates, title, short text description and an icon that will be shown in the popups. The font's size and color of texts in the popups can be set too.

This class is in Poi.h in the EADBrowser.framework of the SDK

@interface Poi : NSObject
    double _lat;
    double _long;
    NSString* _title;
    NSString* _description;
    UIImage* _iconPath;
    UIFont* _poiTitleFont;
    UIFont* _poiDescriptionFont;
    UIColor* _poiTitleColor;
    UIColor* _poiDescriptionColor;
    NSMutableDictionary* _actionsDict;

Here is an example of adding a poi, in viewDidLoad method in ViewController.m add a POI:

- (void)viewDidLoad
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // Hide StatusBar
    // Init ARBrowser viewController
    _arlibCtrl = [[ARglLibController alloc]
    [_arlibCtrl.view setFrame:self.view.frame];
    Poi* firstPoi = [[Poi alloc] init];
    [firstPoi setLocation:[[CLLocation alloc]initWithLatitude:32.781556 longitude:34.965985]];
    [firstPoi setAltitude:5];
    [firstPoi setTitle:@"first poi"];
    [firstPoi setDescription:@"description of first poi"];
    [firstPoi setIconPath:[UIImage imageNamed:@"target.png"]];
    NSMutableDictionary* actions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1111111",POI_ACTION_CALL,@"22222222",POI_ACTION_SMS,@"http://google.com",POI_ACTION_WEBLINK, nil];
    [firstPoi setActionsDict:actions];
    [firstPoi setNotSelectedAlpha:1.0];
    [firstPoi setSelectedAlpha:0.5];
    [_arlibCtrl add:firstPoi];
    [_arlibCtrl start];            
  1. Alloc and init a Poi and set its values: Location, title, description, popup image and the altitude of the poi (variable between 45 degrees and -45). You must set a poi near you (latitude and longitude) if you want see it in the radar. Trick: search in google maps your place, click right button and what's there option.
    In the HelloARLIb sample of the SDK we add several Poi with different images and actions.
  2. Create NSMutableDictionary with values and keys for the action list to let the user have the ability to interact with the poi in various ways (*)
  3. Sets the alpha value applied to the POI for Selected/NonSelected states.
  4. Add the poi we filled with info to the AR Browser.

(*) Actions: A NSDictinary can have the following keys and values:

  • POI_ACTION_CALL with “123456” will call phone “123456”
  • POI_ACTION_WEBLINK with “www.google.com” will open “www.google.com” web page
  • POI_ACTION_EMAIL with “mail@address.com” will open the mail forum to send email to address “mail@address.com”
  • POI_ACTION_SMS with “123456” will send sms to phone number “123456”
  • POI_ACTION_PHOTO with “www.url.com/of/photo.jpg” will open the photo viewer with the photo.jpg in full screen
  • POI_ACTION_AUDIO with “www.url.com/of/audio.mp3” will play the audio file audio.mp3
  • POI_ACTION_VIDEO with “www.url.com/of/video.m4p” will play the video full screen
  • POI_ACTION_FACEBOOK with “nice!” will share the info of the poi (title, description and photo) with the text “nice!” on the user's facebook wall
  • POI_ACTION_TWITTER with “nice!” will share the info of the poi (title, description and photo) with the text “nice!” on the user's twitter account
  • POI_ACTION_MAP with “34.4,36.77” will show the user the map with directions from the user's location to latitude: 34.4 and longitude 36.77

The POI image can be set in two ways:
1.- UIImage: [firstPoi setIconPath:[UIImage imageNamed:@“target.png”]];
2.- URL: [thirdPoi setIconFromUrl:[NSURL URLWithString:@“http://www.arlab.com/img/content/ARLogo.png”]];

The developers can also write custom handlers to get POI clicked and POI selected CALLBACKS:

- (void)viewDidLoad
 [_arlibCtrl setDelegate:self];
- (void) poiClicked:(Poi *)poi
  NSLog(@"Poi [%d] clicked",poi.uId);  
- (void) poiSelected:(Poi *)poi
    NSLog(@"Poi [%d] selected",poi.uId);  

next previous