AfriGIS Map SDK (BB10)  v 1.0.0
Provides easy integration of AfriGIS Maps into BB10 platform.

Introduction to AfrigisMapSDK

This component provides an interface for embedding maps directly into your own windows and views. AfrigisMapSDK also provides support for annotating the map, adding different types of item.

Key Features

Integrating AfrigisMapSDK in your project

Step 1: Open an Blackberry project in Momentics

Step 2: Add the libAfrigisMapSDK.a and include header files in your project

Step 3: Add INCLUDEPATH & LIBS flags like below in the .pro file:

INCLUDEPATH += <Path to the lib header files>
LIBS += -Bstatic -L<path to the lib> -l<lib name> -Bdynamic \

Step 4: Other libraries required:

lpps
lscreen
lEGL
lGLESv1_CM
lfreetype
lpng
lbb
ljpeg
lbbdata
lbbsystem
lbbdevice
lsqlite3
lbbutility

Step 5: Import AfrigisMapSDK.hpp in your .cpp file. e.g.

#include "AfrigisMapSDK.hpp"

How to load a map

Step 1: Implement AGMapViewDelegate in your .cpp class. Modify your cpp's .h file like :

class ClientDemo : public AGMapViewDelegate

After implementing the AGMapViewDelegate you will also need to implement all the abstract methods into your class. And ensure that the pointer object(s) received by these methods are deleted after being used.

For example:

void ClientDemo::onTrackingUpdated(AGGeoInformation *geoInfo)
{
delete(geoInfo);
}

Step 2: In cpp's h file declare a variable like:

AfrigisMapSDK *afrigisMapSDK;

Step 3: Initialize/authenticate mapsdk: In cpp's method add these lines:

//a. prepare mapProperties
Page *mapContainerPage = Page::create();
double centrelat = -28.435;
double centrelon = 24.73;
int zoom = 6;
AfrigisMapSDK::ViewType viewType = AfrigisMapSDK::SatelliteView;
QString serviceName = AGMAP_SERVICE_NAME;
QString serviceKey = AGMAP_SERVICE_KEY;
int mapPositionX = 10;
int mapPositionY = 10;
int mapWidth = 50;
int mapHeight = 50;
// b. initialize map with container page, settings and delegate
afrigisMapSDK = new AfrigisMapSDK(mapContainerPage, centrelat, centrelon, zoom, serviceName, serviceKey, this, viewType, mapPositionX, mapPositionY, mapWidth, mapHeight);

Run the project and you will see that the map is centred on the given geolocation.

How to add a pin.

Step 1: Add a annotation view and add a image item to that annotation view to represent pin:

QList<AGLocationCoordinate2D> *imageCenter = new QList<AGLocationCoordinate2D>();
location.latitude = -28.435;
location.longitude = 24.73;
imageCenter->push_back(location);
QFile file("pin.png");
file.open(QIODevice::ReadOnly);
QByteArray imageByteArray = file.readAll();
int imageWidth = 100;
int imageHeight = 100;
AGOffsetInPixel imageOffset;
imageOffset.offsetX = 50;
imageOffset.offsetY = -50;
ImageItem *imageItem = afrigisMapSDK->createImageItem(imageCenter, &imageByteArray, 100, 100, imageOffset);
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(imageItem);
AnnotationView *annotationView = afrigisMapSDK->addAnnotationView(itemList);
afrigisMapSDK->updateLocation(&location);

How to add circle.

Step 1: Add a annotation view and add a circle item to that annotation view to represent circle:

QList<AGLocationCoordinate2D> *circleCenter = new QList<AGLocationCoordinate2D>();
location.latitude = -28.435;
location.longitude = 24.73;
circleCenter->push_back(location);
float circleRadius = 30.0;
AGOffsetInPixel circleOffset;
circleOffset.offsetX = 50;
circleOffset.offsetY = -50;
QColor *circleColor = new QColor(0, 255, 0, 128);
CircleItem *circleItem = afrigisMapSDK->createCircleItem(circleCenter, circleRadius, circleColor, circleOffset);
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(circleItem);
AnnotationView *annotationView = afrigisMapSDK->addAnnotationView(itemList);
afrigisMapSDK->updateLocation(&location);

How to add polyline.

Step 1: Add a annotation view and add a polyline item to that annotation view to represent polyline:

QList<AGLocationCoordinate2D> *geoLocationCoordinates = new QList<AGLocationCoordinate2D>();
location.latitude = -28.435;
location.longitude = 24.73;
geoLocationCoordinates->push_back(location);
location.latitude = -29.78;
location.longitude = 24.56;
geoLocationCoordinates->push_back(location);
PolylineItem *polylineItem = afrigisMapSDK->createPolylineItem(geoLocationCoordinates, true);
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(polylineItem);
AnnotationView *annotationView = afrigisMapSDK->addAnnotationView(itemList);
afrigisMapSDK->updateLocation(&location);

How to add/remove a route over map

Adding a route

QList<QPair<float,float> > *routeGeoLocationCoordinates = new QList<QPair<float,float> >();
QPair<float,float> location;
location.first = -28.435;
location.second = 24.73;
geoLocationCoordinates->push_back(location);
QPair<float,float> location1;
location1.latitude = -29;
location1.longitude = 245;
geoLocationCoordinates->push_back(location1);
bool startMarkerOn = true;
bool endMarkerOn = true;
QObject *routeView = afrigisMapSDK->addRouteView(routeGeoLocationCoordinates, startMarkerOn, endMarkerOn);

Removing a route

afrigisMapSDK->removeRouteView(routeView);

How to add traffic layer

Add traffic layer over map view.

afrigisMapSDK->addTrafficLayer();

Remove traffic layer

afrigisMapSDK->removeTrafficLayer();