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.
20 #include <maps_plugin.h>
22 #include "here_types.h"
23 #include "here_utils.h"
27 EXPORT_API int maps_plugin_init(maps_plugin_h *plugin)
29 int ret = HerePluginInit(plugin);
31 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
33 return ConvertToMapsError(ret);
36 EXPORT_API int maps_plugin_init_module(maps_plugin_h *plugin, const char *module)
38 int ret = HerePluginInit(plugin, module);
40 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
42 return ConvertToMapsError(ret);
45 EXPORT_API int maps_plugin_shutdown(maps_plugin_h plugin)
47 int ret = HerePluginShutdown(plugin);
49 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
51 return ConvertToMapsError(ret);
54 EXPORT_API int maps_plugin_get_info(maps_plugin_info_h* info)
56 int ret = maps_plugin_info_create(info);
58 if (ret == MAPS_ERROR_NONE)
59 ret = maps_plugin_info_set_provider_name(*info, "HERE");
64 EXPORT_API int maps_plugin_request_user_consent(const char *provider,
65 maps_service_request_user_consent_cb callback,
68 MAPS_LOGD("maps_plugin_request_user_consent");
69 int ret = HerePluginRequestUC(provider, (void *)callback, user_data);
70 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
71 return ConvertToMapsError(ret);
74 EXPORT_API int maps_plugin_request_user_consent_with_handle(maps_service_request_user_consent_with_handle_cb callback,
77 MAPS_LOGD("maps_plugin_request_user_consent_with_handle");
78 int ret = HerePluginRequestUC(NULL, (void *)callback, user_data);
79 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
80 return ConvertToMapsError(ret);
83 EXPORT_API int maps_plugin_get_user_consent(bool *consent)
85 MAPS_LOGD("maps_plugin_get_user_consent");
86 int ret = HerePluginGetUC(consent);
87 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
88 return ConvertToMapsError(ret);
91 EXPORT_API int maps_plugin_set_user_consent(bool consent)
93 MAPS_LOGD("maps_plugin_set_user_consent");
94 int ret = HerePluginSetUserConsent(consent);
95 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
96 return ConvertToMapsError(ret);
99 EXPORT_API int maps_plugin_set_provider_key(const char* provider_key)
101 int ret = HerePluginSetProviderKey(provider_key);
103 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
105 return ConvertToMapsError(ret);
108 EXPORT_API int maps_plugin_get_provider_key(char** provider_key)
110 int ret = HerePluginGetProviderKey(provider_key);
112 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
114 return ConvertToMapsError(ret);
117 EXPORT_API int maps_plugin_set_preference(maps_preference_h preference)
119 int ret = HerePluginSetPreference(preference);
121 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
123 return ConvertToMapsError(ret);
126 EXPORT_API int maps_plugin_get_preference(maps_preference_h* preference)
128 int ret = HerePluginGetPreference(preference);
130 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
132 return ConvertToMapsError(ret);
135 EXPORT_API int maps_plugin_is_service_supported(maps_service_e service, bool *supported)
138 return MAPS_ERROR_INVALID_PARAMETER;
142 case MAPS_SERVICE_GEOCODE:
143 case MAPS_SERVICE_GEOCODE_INSIDE_AREA:
144 case MAPS_SERVICE_GEOCODE_BY_STRUCTURED_ADDRESS:
145 case MAPS_SERVICE_REVERSE_GEOCODE:
146 case MAPS_SERVICE_SEARCH_PLACE:
147 case MAPS_SERVICE_SEARCH_PLACE_BY_AREA:
148 case MAPS_SERVICE_SEARCH_PLACE_BY_ADDRESS:
149 case MAPS_SERVICE_SEARCH_ROUTE:
150 case MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS:
151 case MAPS_SERVICE_CANCEL_REQUEST:
152 case MAPS_SERVICE_MULTI_REVERSE_GEOCODE:
153 case MAPS_SERVICE_SEARCH_PLACE_LIST:
154 case MAPS_SERVICE_SEARCH_GET_PLACE_DETAILS:
155 case MAPS_SERVICE_VIEW:
156 case MAPS_SERVICE_VIEW_SNAPSHOT:
163 return MAPS_ERROR_NONE;
166 EXPORT_API int maps_plugin_is_data_supported(maps_service_data_e service, bool *supported)
169 return MAPS_ERROR_INVALID_PARAMETER;
173 case MAPS_PLACE_ADDRESS:
174 case MAPS_PLACE_RATING:
175 case MAPS_PLACE_CATEGORIES:
176 case MAPS_PLACE_ATTRIBUTES:
177 case MAPS_PLACE_CONTACTS:
178 case MAPS_PLACE_EDITORIALS:
179 case MAPS_PLACE_REVIEWS:
180 case MAPS_PLACE_IMAGE:
181 case MAPS_PLACE_SUPPLIER:
182 case MAPS_PLACE_RELATED:
183 case MAPS_ROUTE_PATH:
184 case MAPS_ROUTE_SEGMENTS_PATH:
185 case MAPS_ROUTE_SEGMENTS_MANEUVERS:
186 case MAPS_VIEW_TRAFFIC:
187 case MAPS_VIEW_PUBLIC_TRANSIT:
188 case MAPS_VIEW_SCALEBAR:
191 case MAPS_VIEW_BUILDING:
196 return MAPS_ERROR_NONE;
199 EXPORT_API int maps_plugin_geocode(const char* address, const maps_preference_h preference,
200 maps_service_geocode_cb callback, void *user_data, int* request_id)
202 int ret = HerePluginGeocode(address, preference, callback, user_data, request_id);
204 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
206 return ConvertToMapsError(ret);
209 EXPORT_API int maps_plugin_geocode_inside_area(const char* address, const maps_area_h bounds,
210 const maps_preference_h preference, maps_service_geocode_cb callback,
211 void* user_data, int* request_id)
213 int ret = HerePluginGeocodeInsideArea(address, bounds, preference, callback, user_data, request_id);
215 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
217 return ConvertToMapsError(ret);
220 EXPORT_API int maps_plugin_geocode_by_structured_address(const maps_address_h address,
221 const maps_preference_h preference, maps_service_geocode_cb callback,
222 void *user_data, int* request_id)
224 int ret = HerePluginGeocodeByStructuredAddress(address, preference, callback, user_data, request_id);
226 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
228 return ConvertToMapsError(ret);
231 EXPORT_API int maps_plugin_reverse_geocode(double latitude, double longitude,
232 const maps_preference_h preference, maps_service_reverse_geocode_cb callback,
233 void *user_data, int* request_id)
235 int ret = HerePluginReverseGeocode(latitude, longitude, preference, callback, user_data, request_id);
237 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
239 return ConvertToMapsError(ret);
242 EXPORT_API int maps_plugin_multi_reverse_geocode(const maps_coordinates_list_h geocode_list,
243 const maps_preference_h preference, maps_service_multi_reverse_geocode_cb callback,
244 void *user_data, int *request_id)
246 int ret = HerePluginMultiReverseGeocode(geocode_list, preference, callback, user_data, request_id);
248 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
250 return ConvertToMapsError(ret);
253 EXPORT_API int maps_plugin_search_place(const maps_coordinates_h position, int distance,
254 const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback,
255 void* user_data, int* request_id)
257 int ret = HerePluginSearchPlace(position, distance, preference, filter, callback, user_data, request_id);
259 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
261 return ConvertToMapsError(ret);
264 EXPORT_API int maps_plugin_search_place_by_area(const maps_area_h boundary,
265 const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback,
266 void* user_data, int* request_id)
268 int ret = HerePluginSearchPlaceByArea(boundary, preference, filter, callback, user_data, request_id);
270 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
272 return ConvertToMapsError(ret);
275 EXPORT_API int maps_plugin_search_place_by_address(const char* address, const maps_area_h boundary,
276 const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback,
277 void* user_data, int* request_id)
279 int ret = HerePluginSearchPlaceByAddress(address, boundary, preference, filter, callback, user_data, request_id);
281 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
283 return ConvertToMapsError(ret);
286 EXPORT_API int maps_plugin_search_place_list(const maps_area_h boundary, const maps_place_filter_h filter,
287 maps_preference_h preference, maps_service_search_place_list_cb callback, void* user_data, int* request_id)
289 int ret = HerePluginSearchPlaceList(boundary, preference, filter, callback, user_data, request_id);
291 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
293 return ConvertToMapsError(ret);
296 EXPORT_API int maps_plugin_get_place_details(const char* url,
297 maps_service_get_place_details_cb callback, void* user_data, int* request_id)
299 int ret = HerePluginSearchPlaceDetails(url, callback, user_data, request_id);
301 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
303 return ConvertToMapsError(ret);
306 EXPORT_API int maps_plugin_search_route(const maps_coordinates_h origin, const maps_coordinates_h destination,
307 maps_preference_h preference, maps_service_search_route_cb callback, void* user_data, int* request_id)
309 int ret = HerePluginSearchRoute(origin, destination, preference, callback, user_data, request_id);
311 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
313 return ConvertToMapsError(ret);
316 EXPORT_API int maps_plugin_search_route_waypoints(const maps_coordinates_h* waypoint_list, int waypoint_num,
317 maps_preference_h preference, maps_service_search_route_cb callback,
318 void* user_data, int* request_id)
320 int ret = HerePluginSearchRouteWaypoints(waypoint_list, waypoint_num, preference, callback, user_data, request_id);
322 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
324 return ConvertToMapsError(ret);
327 EXPORT_API int maps_plugin_cancel_request(int request_id)
329 int ret = HerePluginCancelRequest(request_id);
331 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
333 return ConvertToMapsError(ret);
337 EXPORT_API int maps_plugin_create_map_view(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc)
339 int ret = HerePluginCreateMapView(hView, pCbFunc);
341 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
343 return ConvertToMapsError(ret);
346 EXPORT_API int maps_plugin_destroy_map_view(maps_view_h hView)
348 int ret = HerePluginDestroyMapView(hView);
350 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
352 return ConvertToMapsError(ret);
355 EXPORT_API int maps_plugin_render_map(maps_view_h hView,
356 const maps_coordinates_h coordinates, double zoom_factor, double rotation_angle)
358 int ret = HerePluginRenderMap(hView, coordinates, zoom_factor, rotation_angle);
360 if (ret != HERE_ERROR_NONE)
361 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
363 return ConvertToMapsError(ret);
366 EXPORT_API int maps_plugin_move_center(maps_view_h hView, int delta_x, int delta_y)
368 int ret = HerePluginMoveCenter(hView, delta_x, delta_y);
370 if (ret != HERE_ERROR_NONE)
371 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
373 return ConvertToMapsError(ret);
376 EXPORT_API int maps_plugin_set_scalebar(maps_view_h hView, bool enable)
378 int ret = HerePluginSetScalebar(hView, enable);
380 if (ret != HERE_ERROR_NONE)
381 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
383 return ConvertToMapsError(ret);
386 EXPORT_API int maps_plugin_get_scalebar(maps_view_h hView, bool *enabled)
388 int ret = HerePluginGetScalebar(hView, enabled);
389 return ConvertToMapsError(ret);
392 EXPORT_API int maps_plugin_on_object(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation)
394 int ret = HerePluginOnViewObject(hView, object, operation);
396 if (ret != HERE_ERROR_NONE)
397 MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
399 return ConvertToMapsError(ret);
402 EXPORT_API int maps_plugin_screen_to_geography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord)
404 int ret = HerePluginScreenToGeography(hView, x, y, mapsCoord);
405 return ConvertToMapsError(ret);
408 EXPORT_API int maps_plugin_geography_to_screen(maps_view_h hView, const maps_coordinates_h mapsCoord, int* x, int* y)
410 int ret = HerePluginGeographyToScreen(hView, mapsCoord, x, y);
411 return ConvertToMapsError(ret);
414 EXPORT_API int maps_plugin_get_min_zoom_level(maps_view_h hView, int *min_zoom_level)
416 int ret = HerePluginGetMinZoomLevel(hView, min_zoom_level);
417 return ConvertToMapsError(ret);
420 EXPORT_API int maps_plugin_get_max_zoom_level(maps_view_h hView, int *max_zoom_level)
422 int ret = HerePluginGetMaxZoomLevel(hView, max_zoom_level);
423 return ConvertToMapsError(ret);
426 EXPORT_API int maps_plugin_get_center(maps_view_h hView, maps_coordinates_h *center)
428 int ret = HerePluginGetCenter(hView, center);
429 return ConvertToMapsError(ret);
432 EXPORT_API int maps_plugin_capture_snapshot(maps_view_h view, void **data,
433 int *width, int *height, maps_view_colorspace_type_e *cs)
435 int ret = HerePluginCaptureSnapshot(view, data, width, height, cs);
437 if (ret != HERE_ERROR_NONE)
438 MAPS_LOGD("here_error_e = %d", ret);
440 return ConvertToMapsError(ret);
443 EXPORT_API int maps_plugin_get_view_scale_factor(maps_view_h hView, double *scale)
445 int ret = HerePluginGetViewScale(hView, scale);
446 return ConvertToMapsError(ret);
449 EXPORT_API int maps_plugin_set_view_scale_factor(maps_view_h hView, double scale)
451 int ret = HerePluginSetViewScale(hView, scale);
452 return ConvertToMapsError(ret);
455 } // end of extern "C"