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
- Embed interactive maps into any BB10 application
- Add multiple annotation views to the map
- Add image, circle and polyline items to annotation view
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:
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 :
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:
Step 2: In cpp's h file declare a variable like:
Step 3: Initialize/authenticate mapsdk: In cpp's method add these lines:
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;
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;
imageOffset.offsetX = 50;
imageOffset.offsetY = -50;
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(imageItem);
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;
circleOffset.offsetX = 50;
circleOffset.offsetY = -50;
QColor *circleColor = new QColor(0, 255, 0, 128);
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(circleItem);
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);
QList<Item*> *itemList = new QList<Item*>();
itemList->push_back(polylineItem);
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
How to add traffic layer
Add traffic layer over map view.
Remove traffic layer