AfriGIS Map SDK (BB10)  v 1.0.0
Provides easy integration of AfriGIS Maps into BB10 platform.
AfrigisMapSDK.hpp
1 /*
2  * Copyright (c) 2011, 2012 Research In Motion Limited.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef AFRIGISMAPSDK_HPP
18 #define AFRIGISMAPSDK_HPP
19 
20 #include <QtCore/QObject>
21 #include <bb/system/SystemUiResult>
22 #include "AGMapDataStruct.hpp"
23 
24 namespace bb
25 {
26  namespace cascades
27  {
28  class Page;
29  class AbsoluteLayoutProperties;
30  class ForeignWindowControl;
31  class Container;
32  }
33 }
34 
35 class ViewManager;
36 class MapServerRequest;
37 class AnnotationView;
38 class Item;
39 class PolylineItem;
40 class CircleItem;
41 class ImageItem;
42 class AGMapViewDelegate;
43 
52 class AfrigisMapSDK : public QObject
53 {
54  Q_OBJECT
55  Q_ENUMS(ViewType)
56 // Q_ENUMS(TrackMeType)
57 public:
58  enum ViewType { SatelliteView, MapView };
59 // enum TrackMeType { Accuracy, Direction };
60 
61 public:
62 
79  AfrigisMapSDK(bb::cascades::Page *mapPage,double lat,double lon,int zoom, QString serviceName, QString serviceKey,
80  AGMapViewDelegate* mapViewDelegate, ViewType viewType, int x, int y, int width, int height);
81 
99  AfrigisMapSDK(bb::cascades::Container *mapContainer, double lat, double lon, int zoom, QString serviceName,
100  QString serviceKey, AGMapViewDelegate* mapViewDelegate, ViewType viewType, int x, int y, int width,
101  int height, double scaleX = 1.0, double scaleY = 1.0);
102 
103  ~AfrigisMapSDK();
104 
105 // static void init(QString serviceName, QString serviceKey);
106 
112  void setViewType(ViewType viewType);
113 
121 
129 
136  /* void addPinView();
137  void removePinView();*/
138 
139 public slots:
140 
145  void clearMap();
146 
147 // void locateMe();
148 
153  void removeLocateMe();
154 
163  void trackMe(AGTrackMeType type);
164 
170  void enableLocatingUserInCenter(bool enable);
171 
176  void stopTracking();
177 
182  void stopAndRemoveTracking();
183 
188  void addTrafficLayer();
189 
194  void removeTrafficLayer();
195 
204  QObject* addRouteView(QList<QPair<float,float> > *routeGeoLocationCoordinates, bool startMarkerOn, bool endMarkerOn);
205 
211  void removeRouteView(QObject *routeView);
212 
218  void zoomToExtend(QList<AGLocationCoordinate2D> *listOfPoints);
219 
228  void addPinView(AGGeoInformation *geoInfo,QByteArray *imageData,bool callOutBubbleEnabled, bool contextMenuEnabled);
229 
234  void removePinView();
235 
242  AnnotationView* addAnnotationView(QList<Item*> *itemList = NULL);
243 
249  void removeAnnotationView(AnnotationView* annotationView);
250 
259  PolylineItem* createPolylineItem(QList<AGLocationCoordinate2D> *geoLocationCoordinates, bool enableZoomToExtend, AGOffsetInPixel offset = AGOffsetInPixel());
260 
270  CircleItem* createCircleItem(QList<AGLocationCoordinate2D> *circleCenter, float circleRadius, QColor *circleColor, AGOffsetInPixel offset = AGOffsetInPixel());
271 
282  ImageItem* createImageItem(QList<AGLocationCoordinate2D> *imageCenter, QByteArray *image, int imageWidth, int imageHeight, AGOffsetInPixel offset = AGOffsetInPixel());
283 
290  void updateLocation(AGLocationCoordinate2D *updatedLocationCoordinate = NULL, int zoomLevel = 0);
291 
296  void pauseRender();
297 
302  void resumeRender();
303 
309  void enableZoomInOutButton(bool zoomInOutButtonEnabled);
310 
315  bool isBubbleTouched(double localX, double localY);
316 
322  void setBubbleEnabled(bool bubbleStatus);
323 
328  bool isBubbleEnabled();
329 
330 private slots:
331 
336  void onTrackingStarted(AGSignalType , QList<QVariant>);
337 
342  void onTrackingStopped(AGSignalType , QList<QVariant>);
343 
348  void onUserLocated(AGSignalType , QList<QVariant>);
349 
354  void onUserLocatingFailed(AGSignalType , QList<QVariant>);
355 
360  void onMapViewTouchedDown(AGSignalType, AGGeoInformation*);
361 
362 private:
363 
368  void connectSignals();
369 
374  void emitSignal(AGSignalType signalType, QList<QVariant> params);
375 
376 private:
377 
382  static const int trafficLayerTimeout = 500; //ms
383 
388  QString serviceName;
389 
394  QString serviceKey;
395 
400  ViewManager *viewManager;
401 
406  static MapServerRequest *serverRequest;
407 
412  AGMapViewDelegate *mapViewDelegate;
413 
418  bb::cascades::AbsoluteLayoutProperties *layoutProperties ;
419 
424  bb::cascades::ForeignWindowControl *foreignWindow;
425 
430  bb::cascades::Container* container;
431 
436  ViewType viewType;
437 
438 signals:
439 
444  void signalTrackingStarted();
445 
450  void signalTrackingStopped();
451 
458 
464 
471 };
472 
473 #endif // ifndef AFRIGISMAPSDK_HPP
void clearMap()
clears the map. Removes all pins, annotations, routes and traffic layers.
Definition: AfrigisMapSDK.cpp:468
void removePinView()
remove pin view.
Definition: AfrigisMapSDK.cpp:455
AGLocalPixelCoordinate2D * getLocalPixelFromLatLon(AGLocationCoordinate2D *geoCoordinate)
get device's local pixel coordinate of a latitude-longitude pair.
Definition: AfrigisMapSDK.cpp:437
void signalTrackingStarted()
signal emits when tracking started.
void zoomToExtend(QList< AGLocationCoordinate2D > *listOfPoints)
zoom to extend to show the given list of points fully on map.
Definition: AfrigisMapSDK.cpp:351
void enableZoomInOutButton(bool zoomInOutButtonEnabled)
enable disable zoom in out button.
Definition: AfrigisMapSDK.cpp:230
CircleItem * createCircleItem(QList< AGLocationCoordinate2D > *circleCenter, float circleRadius, QColor *circleColor, AGOffsetInPixel offset=AGOffsetInPixel())
add circle item.
Definition: AfrigisMapSDK.cpp:425
void pauseRender()
private.
Definition: AfrigisMapSDK.cpp:523
void setBubbleEnabled(bool bubbleStatus)
enable disable bubble to show.
Definition: AfrigisMapSDK.cpp:544
The AGMapViewDelegate defines a set of optional methods that you can use to receive map related updat...
Definition: AGMapViewDelegate.h:33
AGLocalPixelCoordinate2D struct for local pixel coordinate.
Definition: AGMapDataStruct.hpp:93
void addPinView(AGGeoInformation *geoInfo, QByteArray *imageData, bool callOutBubbleEnabled, bool contextMenuEnabled)
add pin view to show pin in certain location.
Definition: AfrigisMapSDK.cpp:447
void removeRouteView(QObject *routeView)
remove route view.
Definition: AfrigisMapSDK.cpp:323
Item interface that need to be implemented by all annotation item object. Currently CircleItem...
Definition: Item.hpp:25
AfrigisMapSDK(bb::cascades::Page *mapPage, double lat, double lon, int zoom, QString serviceName, QString serviceKey, AGMapViewDelegate *mapViewDelegate, ViewType viewType, int x, int y, int width, int height)
Constructor to create map.
void removeAnnotationView(AnnotationView *annotationView)
remove annotation view.
Definition: AfrigisMapSDK.cpp:403
void signalUserLocatedWithAccuracy(int)
signal emits when user located after tracking start.
View responsible for presenting annotations visually in map. Annotation view are loosely coupled to a...
Definition: AnnotationView.hpp:29
AGOffsetInPixel Move offset pixel to draw annotation item.
Definition: AGMapDataStruct.hpp:102
void enableLocatingUserInCenter(bool enable)
enable or disable re-centre map in user's current location.
Definition: AfrigisMapSDK.cpp:500
void stopTracking()
stop tracking but show the last tracking position.
Definition: AfrigisMapSDK.cpp:505
void removeLocateMe()
remove locate-me.
Definition: AfrigisMapSDK.cpp:486
Definition: AfrigisMapSDK.hpp:24
Annotation Item object representing a rectangle area on map which is filled with provided image...
Definition: ImageItem.hpp:35
void resumeRender()
private.
Definition: AfrigisMapSDK.cpp:531
Annotation Item object representing a poly-line (example: route) on map. This class manages the data ...
Definition: PolylineItem.hpp:25
PolylineItem * createPolylineItem(QList< AGLocationCoordinate2D > *geoLocationCoordinates, bool enableZoomToExtend, AGOffsetInPixel offset=AGOffsetInPixel())
add poly-line item.
Definition: AfrigisMapSDK.cpp:419
bool isBubbleEnabled()
get bubble enable status.
Definition: AfrigisMapSDK.cpp:549
An AfrigisMapSDK object provides an embeddable map interface. You use this class as-is to display map...
Definition: AfrigisMapSDK.hpp:52
Annotation Item object representing a circular area on map. This class manages the data that defines ...
Definition: CircleItem.hpp:26
void addTrafficLayer()
show traffic layer on map.
Definition: AfrigisMapSDK.cpp:277
ImageItem * createImageItem(QList< AGLocationCoordinate2D > *imageCenter, QByteArray *image, int imageWidth, int imageHeight, AGOffsetInPixel offset=AGOffsetInPixel())
add Image item.
Definition: AfrigisMapSDK.cpp:431
void signalUserLocatingFailed()
signal emits when located user failed.
void removeTrafficLayer()
remove traffic layer.
Definition: AfrigisMapSDK.cpp:293
AGGeoInformation It will provide current bounding box information.
Definition: AGMapDataStruct.hpp:125
void stopAndRemoveTracking()
stop tracking and remove the indicator.
Definition: AfrigisMapSDK.cpp:513
bool isBubbleTouched(double localX, double localY)
private.
Definition: AfrigisMapSDK.cpp:539
AGLocationCoordinate2D struct for latitude and longitude.
Definition: AGMapDataStruct.hpp:83
AGGeoInformation * getCurrentBoundingBox()
get current bounding box informaion.
Definition: AfrigisMapSDK.cpp:271
void setViewType(ViewType viewType)
set different view type of map: SatelliteView, MapView.
Definition: AfrigisMapSDK.cpp:235
AGLocationCoordinate2D * getLatLonFromLocalPixel(AGLocalPixelCoordinate2D *pixelCoordinate)
get latitude-longitude pair of a device's local pixel coordinate.
Definition: AfrigisMapSDK.cpp:442
void signalMapViewTouchedDown(AGGeoInformation *)
signal emits when touch down event occurs on map.
void trackMe(AGTrackMeType type)
Starts track-me.
Definition: AfrigisMapSDK.cpp:494
AnnotationView * addAnnotationView(QList< Item * > *itemList=NULL)
add annotation view.
Definition: AfrigisMapSDK.cpp:387
QObject * addRouteView(QList< QPair< float, float > > *routeGeoLocationCoordinates, bool startMarkerOn, bool endMarkerOn)
show route on map.
Definition: AfrigisMapSDK.cpp:310
void updateLocation(AGLocationCoordinate2D *updatedLocationCoordinate=NULL, int zoomLevel=0)
update centre location of map.
Definition: AfrigisMapSDK.cpp:518
void signalTrackingStopped()
signal emits when tracking stopped.