-
Notifications
You must be signed in to change notification settings - Fork 1
Display Data
As Mixare user you probably want to display (your own) JSON data. The data should display markers on the Augmented Reality view through the Camera.
There are two possibilities to add your own datasource into the application:
- Hardcoded (pre-initialized in the code, not deletable by users)
- Local stored (add through GUI, these are also deletable by GUI)
To add your datasource hardcoded and how the JSON encoding should be, will be explained here below.
Your JSON data encoding for markers/POIs can be customized by your own processor. Read this to create your own dataprocessor. If you don't want to use your own dataprocessor, it will use the default Mixare processor. If you want to use the default Mixare processor, your JSON encoding should be:
{
"status": "OK",
"num_results": 3,
"results": [
{
"id": "2827",
"lat": "46.43893",
"lng": "11.21706",
"elevation": "1737",
"title": "Penegal",
"distance": "9.756",
"webpage": "http%3A%2F%2Fwww.suedtirolerland.it%2Fapi%2Fmap%2FgetMarkerTplM%2F%3Fmarker_id%3D2827%26project_id%3D15%26lang_id%3D9",
"marker": "http://url.com/marker.png", //optional
"logo": "http://url.com/image.png" //optional
},
{
"id": "2821",
"lat": "46.49396",
"lng": "11.2088",
"elevation": "1865",
"title": "Gantkofel",
"distance": "9.771",
"webpage": "",
"marker": "http://url.com/marker.png" //optional
},
{
"id": "2829",
"lat": "46.3591",
"lng": "11.1921",
"elevation": "2116",
"title": "Roen",
"distance": "17.545",
"webpage": "http%3A%2F%2Fwww.suedtirolerland.it%2Fapi%2Fmap%2FgetMarkerTplM%2F%3Fmarker_id%3D2829%26project_id%3D15%26lang_id%3D9",
"marker": "http://url.com/marker.png" //optional
}
]
}
If you want to add fixed datasource, you should add it hardcoded to the object: DataSourceList
.
You should call the method - (void)addDataSource:(NSString*)title dataUrl:(NSString*)url lockDeletable:(BOOL)lock;
If you want to match your DataSource
with your own DataProcessor
, you should give them both the same title.
The 'lockDeletable' parameter gives you the possibility to make it undeletable by users.
Example
#import "DemoDelegate.h"
#import <Mixare/Mixare.h> // Get Mixare Library
@implementation DemoDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add your hardcoded sources
[[DataSourceList getInstance] addDataSource:@"Wikipedia" dataUrl:@"http://ws.geonames.org/findNearbyWikipediaJSON?lat=PARAM_LAT&lng=PARAM_LON&radius=PARAM_RAD&maxRows=50&lang=PARAM_LANG" lockDeletable:YES];
[[DataSourceList getInstance] addDataSource:@"Twitter" dataUrl:@"http://search.twitter.com/search.json?geocode=PARAM_LAT,PARAM_LON,PARAM_RADkm" lockDeletable:YES];
[[DataSourceList getInstance] addDataSource:@"Google Addresses" dataUrl:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=PARAM_LAT,PARAM_LON&sensor=true" lockDeletable:YES];
// Start Application
MixareAppDelegate *delegate = [[MixareAppDelegate alloc] init];
[delegate runApplication];
return YES;
}
@end
Note: This example won't render Wikipedia, Twitter and Google Addresses in the right way. Because it needs the Data Processor plugins for each specific source to read their own JSON encoding structure. In the Mixare project you can copy the specific processors to your own project if you want to try it out by your own. Click here to read more about Data Processor plugins. And click here to read how to add the processor plugin.
Take a look at MixareMain.m
in Mixare source as another example to initialize sources and plugins.