2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <maps_plugin.h>
20 #include <maps_service.h>
21 #include <maps_view.h>
22 #include <maps_view_plugin.h>
24 #include <Ecore_Evas.h>
29 #include "mapzen_types.h"
30 #include "tangram/util/types.h"
36 typedef std::map<maps_view_object_h, Tangram::MarkerID> MapViewObjects;
44 mapzen_error_e create(maps_view_h view, maps_plugin_map_view_ready_cb callback, const char* providerKey);
45 mapzen_error_e destroy(maps_view_h view);
46 mapzen_error_e render(maps_view_h view, const maps_coordinates_h coord, double zoom, double angle);
47 mapzen_error_e moveCenter(maps_view_h view, int delta_x, int delta_y);
48 mapzen_error_e getCenter(maps_view_h view, maps_coordinates_h *center);
49 mapzen_error_e setScalebarEnabled(maps_view_h view, bool enable);
50 mapzen_error_e getScalebarEnabled(maps_view_h view, bool *enabled);
51 mapzen_error_e convertScreenToGeolocation(maps_view_h view, int x, int y, maps_coordinates_h *coord);
52 mapzen_error_e convertGeolocationToScreen(maps_view_h view, const maps_coordinates_h coord, int *x, int *y);
53 mapzen_error_e getMinZoomLevel(maps_view_h view, int *zoom);
54 mapzen_error_e getMaxZoomLevel(maps_view_h view, int *zoom);
55 mapzen_error_e onViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation);
56 mapzen_error_e captureSnapshot(maps_view_h view, void **data, int *width, int *height, maps_view_colorspace_type_e *cs);
58 int getWidth() { return m_w; }
59 int getHeight() { return m_h; }
61 void setSceneLoaded(bool sceneLoaded) { m_sceneLoaded = sceneLoaded; }
62 bool isSceneLoaded() { return m_sceneLoaded; }
65 mapzen_error_e setupOpenGlSurface(maps_view_h view);
66 void setMapType(maps_view_h view);
68 mapzen_error_e addObject(maps_view_object_h object);
69 mapzen_error_e setObjectVisible(maps_view_object_h object, Tangram::MarkerID tvMarker);
70 mapzen_error_e getBitmapMarkerImage(maps_view_object_h object, unsigned char *&imgData, int &imgWidth, int &imgHeight);
71 mapzen_error_e updateObject(maps_view_object_h object, Tangram::MarkerID tvMarker);
72 mapzen_error_e updateMarker(maps_view_object_h object, Tangram::MarkerID tvMarker);
73 mapzen_error_e updatePolyline(maps_view_object_h object, Tangram::MarkerID tvMarker);
74 mapzen_error_e updatePolygon(maps_view_object_h object, Tangram::MarkerID tvMarker);
75 mapzen_error_e removeObject(maps_view_object_h object);
76 MapViewObjects& mapViewObjects() { return m_mapViewObjs; }
77 std::mutex& viewObjectMutex() { return m_viewObjectMutex; }
78 void removeAllObjects();
80 static void sceneLoadedCb(void *data);
81 static void readyMapCb(void *view);
82 static void renderingCb(void *data);
83 static void pixelGetCb(void *data, Evas_Object *obj);
84 // Emplaces the lng/lat from `coordinate` to `user_data` (Tangram::Coordinates)
85 static bool emplaceCoord(int index, maps_coordinates_h coordinate, void *user_data);
87 Tangram::Map *m_map = nullptr;
88 Evas_Object *m_image = nullptr;
89 Evas_GL_Context *m_context = nullptr;
90 Evas_GL_Surface *m_surface = nullptr;
91 Evas_GL_Config *m_config = nullptr;
92 Evas_GL *m_gl = nullptr;
93 Evas_GL_API *m_api = nullptr;
95 bool m_isInitialized = false;
96 bool m_publicTransitEnabled = false;
97 bool m_buildingsEnabled = true;
98 bool m_sceneLoaded = false;
99 std::string m_language = "en";
100 std::string m_providerKey = "";
101 bool m_isProviderKeySet = false;
112 std::mutex m_viewObjectMutex;
114 maps_plugin_map_view_ready_cb m_readyCb = nullptr;
115 tangram_view_type m_viewType = TANGRAM_VIEW_NONE;
117 MapViewObjects m_mapViewObjs; //current set of map objects