2 * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3 * This software, including documentation, is protected by copyright controlled by
4 * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5 * storing, adapting or translating, any or all of this material requires the prior
6 * written consent of HERE Global B.V. You may use this
7 * Software in accordance with the terms and conditions defined in the
8 * HERE Location Platform Services Terms and Conditions, available at
9 * http://developer.here.com/terms-conditions-base
11 * As an additional permission to the above, you may distribute Software,
12 * in object code format as part of an Application, according to, and subject to, terms and
13 * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14 * You may distribute such object code format Application under terms of your choice,
15 * provided that the header and source files of the Software have not been modified.
22 #include <tr1/functional>
24 #include "common/HereMaps_global.h"
26 #ifndef TIZEN_MIGRATION
28 #include <FGraphics.h>
29 #include <FGrpColor.h>
32 #include "maps/DrawableBitmap.h"
33 #ifdef TIZEN_MIGRATION
34 #include "graphic/Dimension.h"
35 #include "graphic/Point.h"
36 #include "graphic/Color.h"
39 using namespace Tizen::Maps;
42 HERE_MAPS_BEGIN_NAMESPACE
48 class TileFetcherReply;
49 class GeoProjectionNode;
50 class GeoMapObjectMarker;
51 class GeoProviderManager;
55 * This class encapsulates a tiled map. The map is composed of square bitmap
56 * tiles retrieved from a grid that represents the normalized Mercator
57 * projection (see also <code>GeoTile</code>). The class supports a number of
58 * map types (for example normal, terrain, satellite, etc.) and provides methods
59 * to control the map size, orientation (heading), zoom level, and managing
60 * objects such as markers, polylines and polygons that can be superimposed on
65 class EXPORT_API GeoTiledMap
70 * This enumeration defines identifiers for supported map types.
74 MT_Normal_Day = 0, ///< Indicates a normal (street/physical
76 MT_Satellite_Day, ///< Indicates a satellite day map.
77 MT_Terrain_Day, ///< Indicates a terrain day map.
78 MT_Hybrid_Day, ///< Indicates a hybrid day map
79 /// (satellite, with roads and labels).
80 #ifdef TIZEN_MIGRATION
82 MT_Normal_Day_Transit,
83 MT_Normal_Night_Transit,
84 MT_Normal_Traffic_Day,
85 MT_Normal_Traffic_Night,
90 MT_Normal_Day_Grey_Mobile,
91 MT_Normal_Day_Transit_Mobile,
92 MT_Normal_Night_Transit_Mobile,
93 MT_Normal_Night_Mobile,
94 MT_Normal_Night_Grey_Mobile,
95 MT_Hybrid_Day_Transit,
97 MT_Hybrid_Traffic_Day,
99 MT_Terrain_Day_Mobile,
101 MT_Pedestrian_Day_Mobile,
103 MT_Pedestrian_Night_Mobile,
108 MT_Last_Entry_Undefined ///< Indicates that the map type is not
113 * This enumeration defines identifiers for logo color.
117 LC_Blue = 0, ///< Indicates that the color is blue.
118 LC_White ///< Indicates that the color is white.
122 * This method is the default constructor.
127 * This method is the (virtual) destructor.
129 virtual ~GeoTiledMap();
132 * This method sets the size of the map.
134 * @param size A constant reference to an object specifying the size of the
135 * map in pixels (width and height).
137 void SetMapSize(const Tizen::Maps::Dimension& size);
140 * This method retrieves the map size.
142 * @return A constant reference to an object containing the width and height
143 * of the map in pixels.
145 const Tizen::Maps::Dimension& GetMapSize() const;
148 * This method sets the map zoom level.
150 * @param zoomLevel A value indicating the new zoom level.
152 #ifdef TIZEN_MIGRATION
153 void SetZoomLevel(double zoomLevel, bool bUpdate=true);
155 void SetZoomLevel(double zoomLevel);
159 * This method retrieves the map zoom level.
161 * @return A value indicating the new zoom level.
163 double GetZoomLevel() const;
166 * This method retrieves the minimum map zoom level.
168 * @return A value indicating the minimum map zoom level.
170 double GetMinimumZoomLevel() const;
172 #ifdef TIZEN_CUSTOMIZATION
174 * This method sets the minimum map zoom level.
176 * @return A value indicating the minimum map zoom level.
178 void SetMinimumZoomLevel(double zoom);
182 * This method retrieves the maximum map zoom level.
184 * @return A value indicating the maximum map zoom level.
186 double GetMaximumZoomLevel() const;
188 #ifdef TIZEN_CUSTOMIZATION
190 * This method sets the maximum map zoom level.
192 * @return A value indicating the maximum map zoom level.
194 void SetMaximumZoomLevel(double zoomLevel);
198 * This method pans the map the caller-specified number of pixels
199 * horizontally and vertically.
201 * @param dx A value indicating the number of pixels to move the map along
202 * the horizontal axis.
204 * @param dy A value indicating the number of pixels to move the map along
207 void Pan(int dx, int dy);
210 * This method sets the coordinates of the map center.
212 * @param center A constant reference to an object containing the new
213 * geographic coordinates of the map center.
215 void SetCenter(const GeoCoordinates& center);
218 * This method retrieves the coordinates of the map center.
220 * @return A constant reference to an object containing the
221 * geographic coordinates of the map center.
223 GeoCoordinates GetCenter() const;
226 * This method renders the given object invalid by resetting the drawable
227 * object representing the map and resetting and reinitializing the tile
233 * This method invalidates (discards) all the map objects, including
236 void InvalidateMapObjects();
238 #ifdef TIZEN_SUPPORT_OPTIMIZATION_OF_REDRAWING
240 * This method invalidates (discards) all the map markers.
242 void InvalidateMapMarkers();
246 * This method invalidates (clears) the cache.
251 * This method clears all the map objects associated with the given tiled
254 void ClearMapObjects();
257 * This method converts the geographic location specified by the caller to
258 * screen coordinates, taking into consideration the current zoom level and
261 * @param coordinate A constant reference to an object containing the
262 * coordinates to convert.
264 * @return An object containing the x and y coordinates defining the screen
267 Tizen::Maps::Point CoordinateToScreenPosition(const GeoCoordinates& coordinate) const;
270 * This method converts the screen position specified by the caller to
271 * geographic coordinates. The method is called, for example, when a marker
272 * is being added to the map.
274 * @param screenPosition An object containing the x and y coordinates
275 * defining the screen location to convert.
277 * @return An object containing the geographic coordinates of corresponding
278 * to the received screen position.
280 GeoCoordinates ScreenPositionToCoordinate(const Tizen::Maps::Point& screenPosition) const;
282 //map objects support
284 * This method adds an object to the map. The object is a marker, a polygon
285 * or polyline, or a group of objects.
287 * @param obj A pointer to an object to add to the map. If the object does
288 * not exist (is <code>NULL</code>), the method has no effect.
290 * @param bTransferOwnership A Boolean value indicating if the ownership of
291 * the map object given in the first parameter should be transferred
292 * to this map instance (<code>true</code>, default) or not
293 * (<code>false</code>). The default behavior transfers the
294 * ownership, which means that the map object becomes responsible for
295 * deleting the markers.
297 void AddObject(GeoMapObject* obj, bool bTransferOwnership=true);
300 * This method removes the object specified by the caller from the map.
302 * @param obj A pointer to the object to remove from the map. If the object
303 * does not exist (is <code>NULL</code>), the method has no effect.
305 * @return Boolean value indicating if the removal of the object was
306 * successful (<code>true</code>) or not (<code>false</code>).
308 bool RemoveObject(GeoMapObject* obj);
311 * This method obtains a pointer to the map object located at the screen
312 * position indicated by the caller.
314 * @param point A constant reference to an object containing the pixel
315 * coordinates of the screen position from which to get the map object.
317 * @return A pointer to the map object at the specified screen location,
318 * otherwise <code>NULL</code> if no map object is found.
320 GeoMapObject* GetObjectAtScreenPosition(const Tizen::Maps::Point& point) const;
323 * This method obtains a count of marker objects in the given tiled map.
325 * @return A value that indicates the number of marker objects.
327 size_t GetNumMarkerObjects() const;
330 * This method retrieves a pointer to a marker object at the index specified
333 * @param idx A value specifying the index of the marker object to
336 * @return A pointer to the marker object at the specified index or
337 * <code>NULL</code> if the index is invalid.
339 GeoMapObjectMarker* GetMarkerObject(size_t idx) const;
341 //draws the map into the current OpenGl context
343 * This method draws (renders and displays) a map image of the size
344 * specified by the caller. The displayed map includes the required map
345 * tiles as well as any objects such as markers, polygons and polylines.
347 * @param uWidth A value specifying the width of the map image.
349 * @param uHeight A value specifying the height of the map image.
351 * @return A Boolean, <code>true</code> if the map has been successfully
352 * pained, otherwise <code>false</code>.
354 bool PaintMap(unsigned int uWidth, unsigned int uHeight);
357 * This typedef defines a function object as a type. The function object can
358 * be called when the map has been updated. A function object of this type
359 * returns <code>void</code> and receives no arguments.
361 #ifdef TIZEN_MIGRATION
362 typedef std::tr1::function<void (void *)> UpdateMapSignalFunctor;
364 typedef std::tr1::function<void ()> UpdateMapSignalFunctor;
368 * This method sets a callback to be invoked when the map has
371 * @param slot A function object to be called when the map has
374 void SetUpdateMapSignal(UpdateMapSignalFunctor slot);
377 * This method sets the map type.
379 * @param aMapType A value indicating the new map type.
381 void SetMapType(MapType aMapType);
384 * This method retrieves the map type.
386 * @return A value indicating the current map type.
388 MapType GetMapType() const;
391 * Available language options are:
392 * L"ara", L"chi", L"cht", L"dut", L"eng", L"ger", L"gle", L"fre", L"ita", L"spa", L"rus", L"pol", L"gre", L"wel"
395 * This method sets the language of the map.
397 * @param aMapLanguage A constant reference to a string containing a
398 * language code. The value of the string must be one of "ara"
399 * (Arabic), "chi" (Chinese), "cht" (Chinese-Taiwan), "dut" (Dutch),
400 * "eng" (English), "ger" (German), "gle" (Irish), "fre" (French),
401 * "ita" (Italian), "spa" (Spanish), "rus" (Russian), "pol" (Polish),
402 * "gre" (Greek), "wel" (Welsh)
404 void SetMapLanguage(const String& aMapLanguage);
407 * This method retrieves the current language of the map.
409 * @return A constant reference to a string containing the language code,
410 * which is one of "ara" (Arabic), "chi" (Chinese), "cht"
411 * (Chinese-Taiwan), "dut" (Dutch), "eng" (English), "ger" (German),
412 * "gle" (Irish), "fre" (French), "ita" (Italian), "spa" (Spanish),
413 * "rus" (Russian), "pol" (Polish), "gre" (Greek), "wel" (Welsh)
415 const String& GetMapLanguage() const;
418 * This method sets the size of the tiles used for rendering the map.
420 * @param uTileSizeInPX Specifies the width and the height of the tiles. Note that
421 * only 128 and 256 are supported as valid values.
423 void SetTileSize(unsigned int uTileSizeInPx);
426 * This method retrieves the size of the tiles, used for rendering the map.
428 * @return An unsigned integer indicating the size of the map tiles.
430 unsigned int GetTileSize() const;
433 * This method changes the background color of the map.
434 * The background color is updated after refreshing the map.
436 * @param color A constant reference to an object representing the new map
439 void SetBackgroundColor(const Tizen::Maps::Color& color);
441 #ifdef TIZEN_CUSTOMIZATION
443 * This method retrieves the root tile, used for rendering the map.
445 * @return An pointer indicating the bitmap of the root tile.
447 DrawableBitmapPtr GetRootPixmap() const;
450 * This method sets a pointer of a structure of the Evas GL API object that
451 * contains the GL APIs to be used in Evas GL.
453 * @param __glapi A pointer to a structure of the Evas GL API object.
455 void SetEvasGlApi(Evas_GL_API *__glapi);
458 * This typedef defines a function object as a type. The function object can
459 * be called when the map has been ready after initialized. A function object of
460 * this type returns <code>void</code> and receives no arguments.
462 typedef void(*ReadyMapSignalFunctor)(void *data);
465 * This method sets a callback to be invoked when the map has
466 * been ready after initialization.
468 * @param slot A function object to be called when the map has
469 * been ready after initialization.
471 void SetReadyMapSignal(ReadyMapSignalFunctor callback, void *data = NULL);
474 * This method sets the angle of the map.
476 * @param angle The angle of the map [-360~360].
478 void SetAngle(double angle);
481 * This method retrieves the angle of the map.
483 * @return A value indicating the angle of the map.
485 double GetAngle() const;
488 * This method sets a Boolean value indicating if the scale bar is enabled or not.
490 * @param enable <code>true</code> if the given status is enabled,
491 * otherwise <code>false</code>.
493 void SetScalebar(bool enable);
496 * This method retrieves a Boolean value indicating if the scale bar is enabled or not.
498 * @return <code>true</code> if the scale bar is enabled, otherwise <code>false</code>.
500 bool GetScalebar() const;
503 #ifdef TIZEN_SUPPORT_TILE_FILE_CACHE
505 * This method invalidates (clears) the file cache for tiles.
507 void ClearTileFileCache();
511 bool HandleTileReady(int level, int x, int y, unsigned int uLevelProvider);
512 bool DrawLogo(UInt uWidth, UInt uHeight, UInt aMapX = 0, UInt aMapY = 0);
514 void UpdateMapSignal();
515 void UpdateProjectionNodes();
516 float CreateProjectionTree(std::vector<GeoProjectionNode*>& result, GeoProjectionNode* node);
517 void InitializeCache();
519 int GetDisplayDPI() const;
521 void SetRootPixmap(DrawableBitmapPtr rootPixmap);
522 #ifdef TIZEN_MIGRATION
523 void ExtendLimitOfCachedTiles();
524 bool DrawScalebar(UInt uWidth, UInt uHeight, UInt aMapX = 0, UInt aMapY = 0);
528 friend class GeoMapObject;
529 friend class GeoMapObjectMarker;
530 friend class GeoProviderManager;
531 friend class TestGeoTiledMap;
532 HERE_MAPS_NO_COPY_NO_ASSIGN(GeoTiledMap);
534 class GeoTiledMapImpl;
535 #ifdef TIZEN_MIGRATION
536 GeoTiledMapImpl *m_pImpl;
538 std::auto_ptr<GeoTiledMapImpl> m_pImpl;
542 HERE_MAPS_END_NAMESPACE
544 #endif // GEOTILEDMAPDATA_H