modified the description about marker size APIs
[platform/core/api/maps-service.git] / src / api / maps_view_object.cpp
1 /* Copyright (c) 2010-2014 Samsung Electronics Co., Ltd. All rights reserved.
2 *
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 #include <glib.h>
18 #include <cairo.h>
19 #include "maps_view_object.h"
20 #include "maps_view_object_plugin.h"
21 #include "maps_error.h"
22 #include "maps_util.h"
23 #include "maps_view.h"
24 #include "maps_extra_types.h"
25 #include "maps_condition.h"
26 #include "marker_constructor.h"
27 #include "polyline_constructor.h"
28 #include "polygon_constructor.h"
29 #include "overlay_constructor.h"
30
31 #ifndef M_PI
32 #define M_PI    3.14159265358979323846
33 #endif
34
35 /*
36 * This represents marker visual object information
37  */
38 typedef struct _maps_view_marker_data_s {
39         maps_coordinates_h coordinates;
40         int width;
41         int height;
42         char *file_path;
43         maps_view_marker_type_e type;
44         int z_order;
45 } maps_view_marker_data_s;
46
47 const gsize _MAPS_VIEW_MARKER_FILE_PATH_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
48
49 /*
50 * This represents polyline visual object information
51  */
52 typedef struct _maps_view_polyline_data_s {
53         /* The list of maps_coordinates_h points, comprising the polyline */
54         maps_coordinates_list_h points;
55
56         /* Line color */
57         unsigned char r;
58         unsigned char g;
59         unsigned char b;
60         unsigned char a;
61
62         /* Line width */
63         int width;
64 } maps_view_polyline_data_s;
65
66 /*
67 * This represents polygon visual object information
68  */
69 typedef struct _maps_view_polygon_data_s {
70         /* The list of maps_coordinates_h points, comprising the polygon */
71         maps_coordinates_list_h points;
72
73         /* The polygon backgraund color */
74         unsigned char r;
75         unsigned char g;
76         unsigned char b;
77         unsigned char a;
78 } maps_view_polygon_data_s;
79
80 typedef struct _maps_view_overlay_data_s {
81         maps_coordinates_h coordinates;
82         Evas_Object *object;
83         int min_zoom_level;
84         int max_zoom_level;
85         maps_view_overlay_type_e type;
86         Evas_Object *bubble;
87         Evas_Object *clipper;
88 } maps_view_overlay_data_s;
89
90 const int _OVERLAY_BUBBLE_MARGIN = 20;
91 const int _OVERLAY_BUBBLE_PIN_SIZE = 20;
92
93 /*
94 * This represents visual object information
95  */
96 typedef struct _maps_view_object_s {
97         maps_view_object_type_e type;   /* marker, polyline, polygon, group */
98         void *shape_data;                               /* Pointer to the visual object data, such as
99                                                                            maps_view_marker_data_s or maps_view_polyline_data_s */
100         bool visible;
101         maps_view_object_h parent_group; /* The group, owning the object */
102         maps_view_h view;       /* Link with the parent Map View */
103 } maps_view_object_s;
104
105 int _maps_view_on_object_operation(maps_view_h view, maps_view_object_h object,
106                                                                 maps_view_object_operation_e operation);
107 int _maps_view_get_parent(const maps_view_h view, Evas_Object **parent);
108 int _maps_view_get_clipper(const maps_view_h view, Evas_Object **clipper);
109
110 static maps_view_h __get_view(const maps_view_object_h object);
111 static maps_view_polyline_data_s *__get_polyline_data(const maps_view_object_h object);
112 static maps_view_polygon_data_s *__get_polygon_data(const maps_view_object_h object);
113 static maps_view_marker_data_s *__get_marker_data(const maps_view_object_h object);
114 static maps_view_overlay_data_s *__get_overlay_data(const maps_view_object_h object);
115
116 static int __maps_view_polyline_data_create(void **polyline);
117 static int __maps_view_polygon_data_create(void **polygon);
118 static int __maps_view_marker_data_create(void **marker);
119 static int __maps_view_overlay_data_create(void **marker);
120
121 static int __maps_view_polyline_data_destroy(void *polyline);
122 static int __maps_view_polygon_data_destroy(void *polygon);
123 static int __maps_view_marker_data_destroy(void *marker);
124 static int __maps_view_overlay_data_destroy(void *marker);
125
126 static maps_view_h __get_view(const maps_view_object_h object)
127 {
128         if (!object)
129                 return NULL;
130         maps_view_object_s *o = (maps_view_object_s *)object;
131         return o->view;
132 }
133
134 static maps_view_polyline_data_s *__get_polyline_data(const maps_view_object_h object)
135 {
136         maps_view_object_s *o = (maps_view_object_s *)object;
137         if (!o || (o->type != MAPS_VIEW_OBJECT_POLYLINE))
138                 return NULL;
139         return (maps_view_polyline_data_s *)o->shape_data;
140 }
141
142 static int __maps_view_polyline_data_create(void **polyline)
143 {
144         if (!polyline)
145                 return MAPS_ERROR_INVALID_PARAMETER;
146
147         int error = MAPS_ERROR_NONE;
148         maps_view_polyline_data_s *p = NULL;
149
150         do {
151                 p = g_slice_new0(maps_view_polyline_data_s);
152                 if (!p) {
153                         MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
154                                   MAPS_ERROR_OUT_OF_MEMORY);
155                         return MAPS_ERROR_OUT_OF_MEMORY;
156                 }
157
158                 error = maps_coordinates_list_create(&p->points);
159                 if (error != MAPS_ERROR_NONE)
160                         break;
161
162                 *polyline = (maps_view_polyline_data_s *) p;
163                 return MAPS_ERROR_NONE;
164         } while (false);
165
166         __maps_view_polyline_data_destroy(p);
167         return error;
168 }
169
170 static int __maps_view_polyline_data_destroy(void *polyline)
171 {
172         if (!polyline)
173                 return MAPS_ERROR_INVALID_PARAMETER;
174
175         maps_view_polyline_data_s *p = (maps_view_polyline_data_s *)polyline;
176         if (p->points)
177                 maps_coordinates_list_destroy(p->points);
178
179         g_slice_free(maps_view_polyline_data_s, p);
180
181         return MAPS_ERROR_NONE;
182 }
183
184 static maps_view_polygon_data_s *__get_polygon_data(const maps_view_object_h object)
185 {
186         maps_view_object_s *o = (maps_view_object_s *)object;
187         if (!o || (o->type != MAPS_VIEW_OBJECT_POLYGON))
188                 return NULL;
189         return (maps_view_polygon_data_s *)o->shape_data;
190 }
191
192 static int __maps_view_polygon_data_create(void **polygon)
193 {
194         if (!polygon)
195                 return MAPS_ERROR_INVALID_PARAMETER;
196
197         int error = MAPS_ERROR_NONE;
198         maps_view_polygon_data_s *p = NULL;
199
200         do {
201                 p = g_slice_new0(maps_view_polygon_data_s);
202                 if (!p) {
203                         MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
204                                   MAPS_ERROR_OUT_OF_MEMORY);
205                         return MAPS_ERROR_OUT_OF_MEMORY;
206                 }
207
208                 error = maps_coordinates_list_create(&p->points);
209                 if (error != MAPS_ERROR_NONE)
210                         break;
211
212                 *polygon = (maps_view_polygon_data_s *) p;
213                 return MAPS_ERROR_NONE;
214         } while (false);
215
216         __maps_view_polygon_data_destroy(p);
217         return error;
218 }
219
220 static int __maps_view_polygon_data_destroy(void *polygon)
221 {
222         if (!polygon)
223                 return MAPS_ERROR_INVALID_PARAMETER;
224
225         maps_view_polygon_data_s *p = (maps_view_polygon_data_s *)polygon;
226         if (p->points)
227                 maps_coordinates_list_destroy(p->points);
228
229         g_slice_free(maps_view_polygon_data_s, p);
230
231         return MAPS_ERROR_NONE;
232 }
233
234 static maps_view_marker_data_s *__get_marker_data(const maps_view_object_h object)
235 {
236         maps_view_object_s *o = (maps_view_object_s *)object;
237         if (!o || (o->type != MAPS_VIEW_OBJECT_MARKER))
238                 return NULL;
239         return (maps_view_marker_data_s *)o->shape_data;
240 }
241
242 static int __maps_view_marker_data_create(void **marker)
243 {
244         if (!marker)
245                 return MAPS_ERROR_INVALID_PARAMETER;
246
247
248         int error = MAPS_ERROR_NONE;
249         maps_view_marker_data_s *m = NULL;
250
251         do {
252                 m = g_slice_new0(maps_view_marker_data_s);
253                 if (!m) {
254                         MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
255                                   MAPS_ERROR_OUT_OF_MEMORY);
256                         return MAPS_ERROR_OUT_OF_MEMORY;
257                 }
258
259                 error = maps_coordinates_create(.0, .0, &m->coordinates);
260                 if (error != MAPS_ERROR_NONE)
261                         break;
262
263                 m->type = MAPS_VIEW_MARKER_PIN;
264                 m->width = 0;
265                 m->height = 0;
266                 m->z_order = 0;
267                 *marker = (maps_view_marker_data_s *) m;
268                 return MAPS_ERROR_NONE;
269         } while (false);
270
271         __maps_view_marker_data_destroy(m);
272         return error;
273 }
274
275 static int __maps_view_marker_data_destroy(void *marker)
276 {
277         if (!marker)
278                 return MAPS_ERROR_INVALID_PARAMETER;
279
280         maps_view_marker_data_s *m = (maps_view_marker_data_s *)marker;
281         if (m->coordinates)
282                 maps_coordinates_destroy(m->coordinates);
283
284         if (m->file_path)
285                 g_free(m->file_path);
286
287         g_slice_free(maps_view_marker_data_s, m);
288
289         return MAPS_ERROR_NONE;
290 }
291
292 static maps_view_overlay_data_s *__get_overlay_data(const maps_view_object_h object)
293 {
294         maps_view_object_s *o = (maps_view_object_s *)object;
295         if (!o || (o->type != MAPS_VIEW_OBJECT_OVERLAY))
296                 return NULL;
297         return (maps_view_overlay_data_s *)o->shape_data;
298 }
299
300 static int __maps_view_overlay_data_create(void **overlay)
301 {
302         if (!overlay)
303                 return MAPS_ERROR_INVALID_PARAMETER;
304
305         int error = MAPS_ERROR_NONE;
306         maps_view_overlay_data_s *m = NULL;
307
308         do {
309                 m = g_slice_new0(maps_view_overlay_data_s);
310                 if (!m) {
311                         MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
312                                   MAPS_ERROR_OUT_OF_MEMORY);
313                         return MAPS_ERROR_OUT_OF_MEMORY;
314                 }
315
316                 error = maps_coordinates_create(.0, .0, &m->coordinates);
317                 if (error != MAPS_ERROR_NONE)
318                         break;
319
320                 *overlay = (maps_view_overlay_data_s *) m;
321                 return MAPS_ERROR_NONE;
322         } while (false);
323
324         __maps_view_overlay_data_destroy(m);
325         return error;
326 }
327
328 static int __maps_view_overlay_data_destroy(void *overlay)
329 {
330         if (!overlay)
331                 return MAPS_ERROR_INVALID_PARAMETER;
332
333         maps_view_overlay_data_s *m = (maps_view_overlay_data_s *)overlay;
334
335         if (m->coordinates)
336                 maps_coordinates_destroy(m->coordinates);
337
338         if (m->object)
339                 evas_object_del(m->object);
340
341         if (m->bubble)
342                 evas_object_del(m->bubble);
343
344         if (m->clipper) {
345                 const Eina_List *clipees = evas_object_clipees_get(m->clipper);
346                 if (!clipees || eina_list_count(clipees) == 0) {
347                         evas_object_hide(m->clipper);
348                         MAPS_LOGD("hide clipper");
349                 }
350         }
351
352         g_slice_free(maps_view_overlay_data_s, m);
353
354         return MAPS_ERROR_NONE;
355 }
356
357 int _maps_view_object_create(maps_view_object_type_e type, maps_view_object_h *object)
358 {
359         if (!object)
360                 return MAPS_ERROR_INVALID_PARAMETER;
361         if (type < MAPS_VIEW_OBJECT_POLYLINE || type > MAPS_VIEW_OBJECT_OVERLAY)
362                 return MAPS_ERROR_INVALID_PARAMETER;
363
364         int error = MAPS_ERROR_NONE;
365         maps_view_object_s *o = NULL;
366
367         do {
368                 o = g_slice_new0(maps_view_object_s);
369                 if (!o) {
370                         MAPS_LOGE("OUT_OF_MEMORY(0x%08x)",
371                                   MAPS_ERROR_OUT_OF_MEMORY);
372                         return MAPS_ERROR_OUT_OF_MEMORY;
373                 }
374
375                 o->type = type;
376                 o->view = NULL;
377                 o->visible = true;
378
379                 int error = MAPS_ERROR_NONE;
380                 switch(o->type) {
381                 case MAPS_VIEW_OBJECT_POLYLINE:
382                         error = __maps_view_polyline_data_create(&o->shape_data);
383                         break;
384                 case MAPS_VIEW_OBJECT_POLYGON:
385                         error = __maps_view_polygon_data_create(&o->shape_data);
386                         break;
387                 case MAPS_VIEW_OBJECT_MARKER:
388                         error = __maps_view_marker_data_create(&o->shape_data);
389                         break;
390                 case MAPS_VIEW_OBJECT_OVERLAY:
391                         error = __maps_view_overlay_data_create(&o->shape_data);
392                         break;
393                 default:
394                         break;
395                 }
396
397                 if ((!o->shape_data) || (error != MAPS_ERROR_NONE))
398                         break;
399
400                 /* Notify view, that the object was constructed */
401                 /*if (view)
402                   _maps_view_on_object_operation(view,
403                   o,
404                   MAPS_VIEW_OBJECT_ADD);*/
405
406                 *object = (maps_view_object_h) o;
407                 return MAPS_ERROR_NONE;
408         } while (false);
409         maps_view_object_destroy(o);
410         return error;
411 }
412
413 int _maps_view_object_set_view(maps_view_object_h object, maps_view_h view)
414 {
415         if (!object || !view)
416                 return MAPS_ERROR_INVALID_PARAMETER;
417
418         maps_view_object_s *o = (maps_view_object_s *) object;
419         o->view = view;
420
421         maps_view_object_type_e type;
422         maps_view_object_get_type(object, &type);
423         if (type == MAPS_VIEW_OBJECT_OVERLAY)   {
424                 int min_zoom = 0, max_zoom = 0;
425                 maps_view_object_overlay_get_min_zoom_level(object, &min_zoom);
426                 maps_view_object_overlay_get_max_zoom_level(object, &max_zoom);
427                 if (min_zoom == 0) {
428                         maps_view_get_min_zoom_level(view, &min_zoom);
429                         maps_view_object_overlay_set_min_zoom_level(object, min_zoom);
430                 }
431                 if (max_zoom == 0) {
432                         maps_view_get_max_zoom_level(view, &max_zoom);
433                         maps_view_object_overlay_set_max_zoom_level(object, max_zoom);
434                 }
435         }
436         return MAPS_ERROR_NONE;
437 }
438
439 EXPORT_API int maps_view_object_create_marker(maps_coordinates_h coordinates,
440         const char *image_file_path, maps_view_marker_type_e type, maps_view_object_h *marker)
441 {
442         if (!maps_condition_check_maps_feature())
443                 return MAPS_ERROR_NOT_SUPPORTED;
444         if (!coordinates || !marker)
445                 return MAPS_ERROR_INVALID_PARAMETER;
446         if (type < MAPS_VIEW_MARKER_PIN || type > MAPS_VIEW_MARKER_STICKER)
447                 return MAPS_ERROR_INVALID_PARAMETER;
448
449         /* Create a Marker Visual Object */
450         view::marker_constructor mc;
451         *marker = mc.construct(coordinates, image_file_path, type);
452         if (mc.get_error() == MAPS_ERROR_NONE)
453                 return mc.get_error();
454
455         /* Marker create failure */
456         maps_view_object_destroy(*marker);
457         *marker = NULL;
458         return mc.get_error();
459 }
460
461 EXPORT_API int maps_view_object_create_polyline(maps_coordinates_list_h coordinates,
462         unsigned char r, unsigned char g, unsigned char b, unsigned char a, int width,
463         maps_view_object_h *polyline)
464 {
465         if (!maps_condition_check_maps_feature())
466                 return MAPS_ERROR_NOT_SUPPORTED;
467         if (!coordinates || !polyline || width < 1 || width > 100)
468                 return MAPS_ERROR_INVALID_PARAMETER;
469
470         /* Create a Polyline Visual Object */
471         view::polyline_constructor pc;
472         *polyline = pc.construct(coordinates, r, g, b, a, width);
473         if (pc.get_error() == MAPS_ERROR_NONE)
474                 return pc.get_error();
475
476         /* Polyline create failure */
477         maps_view_object_destroy(*polyline);
478         *polyline = NULL;
479         return pc.get_error();
480 }
481
482 EXPORT_API int maps_view_object_create_polygon(maps_coordinates_list_h coordinates,
483         unsigned char r, unsigned char g, unsigned char b, unsigned char a, maps_view_object_h *polygon)
484 {
485         if (!maps_condition_check_maps_feature())
486                 return MAPS_ERROR_NOT_SUPPORTED;
487         if (!coordinates || !polygon)
488                 return MAPS_ERROR_INVALID_PARAMETER;
489
490         /* Create a Polygon Visual Object */
491         view::polygon_constructor pc;
492         *polygon = pc.construct(coordinates, r, g, b, a);
493         if (pc.get_error() == MAPS_ERROR_NONE)
494                 return pc.get_error();
495
496         /* Polygon create failure */
497         maps_view_object_destroy(*polygon);
498         *polygon = NULL;
499         return pc.get_error();
500 }
501
502 EXPORT_API int maps_view_object_create_overlay(maps_coordinates_h coordinates,
503         Evas_Object *object, maps_view_overlay_type_e type, maps_view_object_h *overlay)
504 {
505         if (!maps_condition_check_maps_feature())
506                 return MAPS_ERROR_NOT_SUPPORTED;
507         if (!overlay || !coordinates)
508                 return MAPS_ERROR_INVALID_PARAMETER;
509         if (type < MAPS_VIEW_OVERLAY_NORMAL || type > MAPS_VIEW_OVERLAY_BOX)
510                 return MAPS_ERROR_INVALID_PARAMETER;
511
512         double lat, lon;
513         maps_coordinates_get_latitude_longitude(coordinates, &lat, &lon);
514
515         /* Create a Overlay Visual Object */
516         view::overlay_constructor pc;
517         *overlay = pc.construct(coordinates, object, type);
518         if (pc.get_error() == MAPS_ERROR_NONE)
519                 return pc.get_error();
520
521         /* Overlay create failure */
522         maps_view_object_destroy(*overlay);
523         *overlay = NULL;
524         return pc.get_error();
525 }
526
527 EXPORT_API int maps_view_object_destroy(maps_view_object_h object)
528 {
529         if (!maps_condition_check_maps_feature())
530                 return MAPS_ERROR_NOT_SUPPORTED;
531         if (!object)
532                 return MAPS_ERROR_INVALID_PARAMETER;
533
534         maps_view_object_s *o = (maps_view_object_s *) object;
535
536         /* Notify view, that the object is to be destroyed shortly */
537         _maps_view_on_object_operation(o->view, o, MAPS_VIEW_OBJECT_REMOVE);
538
539         int error = MAPS_ERROR_NONE;
540         switch(o->type) {
541         case MAPS_VIEW_OBJECT_POLYLINE:
542                 error = __maps_view_polyline_data_destroy(o->shape_data);
543                 break;
544         case MAPS_VIEW_OBJECT_POLYGON:
545                 error = __maps_view_polygon_data_destroy(o->shape_data);
546                 break;
547         case MAPS_VIEW_OBJECT_MARKER:
548                 error = __maps_view_marker_data_destroy(o->shape_data);
549                 break;
550         case MAPS_VIEW_OBJECT_OVERLAY:
551                 error = __maps_view_overlay_data_destroy(o->shape_data);
552                 break;
553         default:
554                 break;
555         }
556         g_slice_free(maps_view_object_s, object);
557         return error;
558 }
559
560 EXPORT_API int maps_view_object_get_type(maps_view_object_h object, maps_view_object_type_e *type)
561 {
562         if (!maps_condition_check_maps_feature())
563                 return MAPS_ERROR_NOT_SUPPORTED;
564         if (!object || !type)
565                 return MAPS_ERROR_INVALID_PARAMETER;
566         *type = ((maps_view_object_s *)object)->type;
567         return MAPS_ERROR_NONE;
568 }
569
570
571 /**
572 * Visual Object Operations
573  */
574
575 EXPORT_API int maps_view_object_set_visible(maps_view_object_h object, bool visible)
576 {
577         if (!maps_condition_check_maps_feature())
578                 return MAPS_ERROR_NOT_SUPPORTED;
579         if (!object)
580                 return MAPS_ERROR_INVALID_PARAMETER;
581         maps_view_object_s *o = (maps_view_object_s *)object;
582         o->visible = visible;
583
584         /* Notify view, that the object visibility is changed */
585         _maps_view_on_object_operation(o->view, o, MAPS_VIEW_OBJECT_SET_VISIBLE);
586
587         return MAPS_ERROR_NONE;
588 }
589
590 EXPORT_API int maps_view_object_get_visible(const maps_view_object_h object, bool *visible)
591 {
592         if (!maps_condition_check_maps_feature())
593                 return MAPS_ERROR_NOT_SUPPORTED;
594         if (!object || !visible)
595                 return MAPS_ERROR_INVALID_PARAMETER;
596         maps_view_object_s *o = (maps_view_object_s *)object;
597         *visible = o->visible;
598         return MAPS_ERROR_NONE;
599 }
600
601
602 /*----------------------------------------------------------------------------*/
603 /*
604 * Polyline
605  */
606
607 EXPORT_API int maps_view_object_polyline_set_polyline(maps_view_object_h polyline,
608                                                                 maps_coordinates_list_h points)
609 {
610         if (!maps_condition_check_maps_feature())
611                 return MAPS_ERROR_NOT_SUPPORTED;
612         if (!polyline || !points)
613                 return MAPS_ERROR_INVALID_PARAMETER;
614
615         /* Get the polyline data pointer */
616         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
617         if (!p)
618                 return MAPS_ERROR_INVALID_PARAMETER;
619
620         /* Set new polyline trajectory */
621         maps_coordinates_list_destroy(p->points);
622         p->points = points;
623
624         /* Notify view, that the object specific preferences is changed */
625         _maps_view_on_object_operation(__get_view(polyline), polyline, MAPS_VIEW_OBJECT_CHANGE);
626
627         return MAPS_ERROR_NONE;
628 }
629
630 EXPORT_API int maps_view_object_polyline_foreach_point(maps_view_object_h polyline,
631                                                                 maps_coordinates_cb callback, void *user_data)
632 {
633         if (!maps_condition_check_maps_feature())
634                 return MAPS_ERROR_NOT_SUPPORTED;
635         if (!polyline || !callback)
636                 return MAPS_ERROR_INVALID_PARAMETER;
637
638         /* Get the polyline data pointer */
639         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
640         if (!p)
641                 return MAPS_ERROR_INVALID_PARAMETER;
642         if (!p->points)
643                 return MAPS_ERROR_NOT_FOUND;
644
645         /* Iterate over polyline trajectory */
646         return maps_coordinates_list_foreach(p->points, callback, user_data);
647 }
648
649 EXPORT_API int maps_view_object_polyline_set_color(maps_view_object_h polyline,
650         unsigned char r, unsigned char g, unsigned char b, unsigned char a)
651 {
652         if (!maps_condition_check_maps_feature())
653                 return MAPS_ERROR_NOT_SUPPORTED;
654         if (!polyline)
655                 return MAPS_ERROR_INVALID_PARAMETER;
656
657         /* Get the polyline data pointer */
658         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
659         if (!p)
660                 return MAPS_ERROR_INVALID_PARAMETER;
661
662         /* Set new color */
663         p->r = r;
664         p->g = g;
665         p->b = b;
666         p->a = a;
667
668         /* Notify view, that the object specific preferences is changed */
669         _maps_view_on_object_operation(__get_view(polyline), polyline, MAPS_VIEW_OBJECT_CHANGE);
670
671         return MAPS_ERROR_NONE;
672 }
673
674 EXPORT_API int maps_view_object_polyline_get_color(const maps_view_object_h polyline,
675         unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
676 {
677         if (!maps_condition_check_maps_feature())
678                 return MAPS_ERROR_NOT_SUPPORTED;
679         if (!polyline || (!r && !g && !b && !a))
680                 return MAPS_ERROR_INVALID_PARAMETER;
681
682         /* Get the polyline data pointer */
683         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
684         if (!p)
685                 return MAPS_ERROR_INVALID_PARAMETER;
686
687         /* Retrieve the color */
688         if (r)
689                 *r = p->r;
690         if (g)
691                 *g = p->g;
692         if (b)
693                 *b = p->b;
694         if (a)
695                 *a = p->a;
696         return MAPS_ERROR_NONE;
697 }
698
699
700 EXPORT_API int maps_view_object_polyline_set_width(maps_view_object_h polyline, int width)
701 {
702         if (!maps_condition_check_maps_feature())
703                 return MAPS_ERROR_NOT_SUPPORTED;
704         if (!polyline)
705                 return MAPS_ERROR_INVALID_PARAMETER;
706         if (width < 0 || width > 100)
707                 return MAPS_ERROR_INVALID_PARAMETER;
708
709         /* Get the polyline data pointer */
710         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
711         if (!p)
712                 return MAPS_ERROR_INVALID_PARAMETER;
713
714         /* Update the width of polyline */
715         p->width = width;
716
717         /* Notify view, that the object specific preferences is changed */
718         _maps_view_on_object_operation(__get_view(polyline), polyline, MAPS_VIEW_OBJECT_CHANGE);
719
720         return MAPS_ERROR_NONE;
721 }
722
723 EXPORT_API int maps_view_object_polyline_get_width(const maps_view_object_h polyline, int *width)
724 {
725         if (!maps_condition_check_maps_feature())
726                 return MAPS_ERROR_NOT_SUPPORTED;
727         if (!polyline || !width)
728                 return MAPS_ERROR_INVALID_PARAMETER;
729
730         /* Get the polyline data pointer */
731         maps_view_polyline_data_s *p = __get_polyline_data(polyline);
732         if (!p)
733                 return MAPS_ERROR_INVALID_PARAMETER;
734
735         /* Retrieve the width of the polyline */
736         *width = p->width;
737         return MAPS_ERROR_NONE;
738 }
739
740 /*----------------------------------------------------------------------------*/
741 /*
742 * Polygon
743  */
744
745 EXPORT_API int maps_view_object_polygon_set_polygon(maps_view_object_h polygon, maps_coordinates_list_h points)
746 {
747         if (!maps_condition_check_maps_feature())
748                 return MAPS_ERROR_NOT_SUPPORTED;
749         if (!polygon || !points)
750                 return MAPS_ERROR_INVALID_PARAMETER;
751
752         /* Get the polygon data pointer */
753         maps_view_polygon_data_s *p = __get_polygon_data(polygon);
754         if (!p)
755                 return MAPS_ERROR_INVALID_PARAMETER;
756
757         /* Set new polygon border */
758         maps_coordinates_list_destroy(p->points);
759         p->points = points;
760
761         /* Notify view, that the object specific preferences is changed */
762         _maps_view_on_object_operation(__get_view(polygon), polygon, MAPS_VIEW_OBJECT_CHANGE);
763
764         return MAPS_ERROR_NONE;
765 }
766
767 EXPORT_API int maps_view_object_polygon_foreach_point(maps_view_object_h polygon,
768         maps_coordinates_cb callback, void *user_data)
769 {
770         if (!maps_condition_check_maps_feature())
771                 return MAPS_ERROR_NOT_SUPPORTED;
772         if (!polygon || !callback)
773                 return MAPS_ERROR_INVALID_PARAMETER;
774
775         /* Get the polygon data pointer */
776         maps_view_polygon_data_s *p = __get_polygon_data(polygon);
777         if (!p)
778                 return MAPS_ERROR_INVALID_PARAMETER;
779         if (!p->points)
780                 return MAPS_ERROR_NOT_FOUND;
781
782         /* Iterate over polygon border */
783         return maps_coordinates_list_foreach(p->points, callback, user_data);
784 }
785
786
787 EXPORT_API int maps_view_object_polygon_set_fill_color(maps_view_object_h polygon,
788         unsigned char r, unsigned char g, unsigned char b, unsigned char a)
789 {
790         if (!maps_condition_check_maps_feature())
791                 return MAPS_ERROR_NOT_SUPPORTED;
792         if (!polygon)
793                 return MAPS_ERROR_INVALID_PARAMETER;
794
795         /* Get the polygon data pointer */
796         maps_view_polygon_data_s *p = __get_polygon_data(polygon);
797         if (!p)
798                 return MAPS_ERROR_INVALID_PARAMETER;
799
800         /* Set new background color */
801         p->r = r;
802         p->g = g;
803         p->b = b;
804         p->a = a;
805
806         /* Notify view, that the object specific preferences is changed */
807         _maps_view_on_object_operation(__get_view(polygon), polygon, MAPS_VIEW_OBJECT_CHANGE);
808
809         return MAPS_ERROR_NONE;
810 }
811
812 EXPORT_API int maps_view_object_polygon_get_fill_color(const maps_view_object_h polygon,
813         unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
814 {
815         if (!maps_condition_check_maps_feature())
816                 return MAPS_ERROR_NOT_SUPPORTED;
817         if (!polygon || (!r && !g && !b && !a))
818                 return MAPS_ERROR_INVALID_PARAMETER;
819
820         /* Get the polygon data pointer */
821         maps_view_polygon_data_s *p = __get_polygon_data(polygon);
822         if (!p)
823                 return MAPS_ERROR_INVALID_PARAMETER;
824
825         /* Retrieve the background color */
826         if (r)
827                 *r = p->r;
828         if (g)
829                 *g = p->g;
830         if (b)
831                 *b = p->b;
832         if (a)
833                 *a = p->a;
834         return MAPS_ERROR_NONE;
835 }
836
837
838 /*----------------------------------------------------------------------------*/
839 /*
840 * Marker
841  */
842
843 EXPORT_API int maps_view_object_marker_set_coordinates(maps_view_object_h marker,
844         maps_coordinates_h coordinates)
845 {
846         if (!maps_condition_check_maps_feature())
847                 return MAPS_ERROR_NOT_SUPPORTED;
848         if (!marker || !coordinates)
849                 return MAPS_ERROR_INVALID_PARAMETER;
850         maps_view_marker_data_s *m = __get_marker_data(marker);
851         if (!m)
852                 return MAPS_ERROR_INVALID_PARAMETER;
853         if (m->coordinates)
854                 maps_coordinates_destroy(m->coordinates);
855         m->coordinates = coordinates;
856
857         /* Notify view, that the object specific preferences is changed */
858         _maps_view_on_object_operation(__get_view(marker), marker, MAPS_VIEW_OBJECT_CHANGE);
859
860         return MAPS_ERROR_NONE;
861 }
862
863 EXPORT_API int maps_view_object_marker_resize(maps_view_object_h marker, int width, int height)
864 {
865         if (!maps_condition_check_maps_feature())
866                 return MAPS_ERROR_NOT_SUPPORTED;
867         if (!marker || width < 0 || height < 0)
868                 return MAPS_ERROR_INVALID_PARAMETER;
869         maps_view_marker_data_s *m = __get_marker_data(marker);
870         if (!m)
871                 return MAPS_ERROR_INVALID_PARAMETER;
872         m->width = width;
873         m->height = height;
874
875         /* Notify view, that the object specific preferences is changed */
876         _maps_view_on_object_operation(__get_view(marker), marker, MAPS_VIEW_OBJECT_CHANGE);
877
878         return MAPS_ERROR_NONE;
879 }
880
881 EXPORT_API int maps_view_object_marker_set_image_file(maps_view_object_h marker, const char *file_path)
882 {
883         if (!maps_condition_check_maps_feature())
884                 return MAPS_ERROR_NOT_SUPPORTED;
885         if (!marker || !file_path)
886                 return MAPS_ERROR_INVALID_PARAMETER;
887         maps_view_marker_data_s *m = __get_marker_data(marker);
888         if (!m)
889                 return MAPS_ERROR_INVALID_PARAMETER;
890         const int error = maps_set_string(file_path, _MAPS_VIEW_MARKER_FILE_PATH_MAX_LENGTH, &m->file_path);
891
892         /* Notify view, that the object specific preferences is changed */
893         if (error == MAPS_ERROR_NONE)
894                 _maps_view_on_object_operation(__get_view(marker), marker, MAPS_VIEW_OBJECT_CHANGE);
895
896         return error;
897 }
898
899 EXPORT_API int maps_view_object_marker_get_image_file(const maps_view_object_h marker, char **file_path)
900 {
901         if (!maps_condition_check_maps_feature())
902                 return MAPS_ERROR_NOT_SUPPORTED;
903         if (!marker || !file_path)
904                 return MAPS_ERROR_INVALID_PARAMETER;
905         maps_view_marker_data_s *m = __get_marker_data(marker);
906         if (!m)
907                 return MAPS_ERROR_INVALID_PARAMETER;
908         return maps_get_string(m->file_path, _MAPS_VIEW_MARKER_FILE_PATH_MAX_LENGTH, file_path);
909 }
910
911 EXPORT_API int maps_view_object_marker_get_coordinates(const maps_view_object_h marker, maps_coordinates_h *coordinates)
912 {
913         if (!maps_condition_check_maps_feature())
914                 return MAPS_ERROR_NOT_SUPPORTED;
915         if (!marker || !coordinates)
916                 return MAPS_ERROR_INVALID_PARAMETER;
917         maps_view_marker_data_s *m = __get_marker_data(marker);
918         if (!m)
919                 return MAPS_ERROR_INVALID_PARAMETER;
920         return maps_coordinates_clone(m->coordinates, coordinates);
921 }
922
923 EXPORT_API int maps_view_object_marker_set_size(maps_view_object_h marker, int width, int height)
924 {
925         if (!maps_condition_check_maps_feature())
926                 return MAPS_ERROR_NOT_SUPPORTED;
927         if (!marker || width < 0 || height < 0)
928                 return MAPS_ERROR_INVALID_PARAMETER;
929         maps_view_marker_data_s *m = __get_marker_data(marker);
930         if (!m)
931                 return MAPS_ERROR_INVALID_PARAMETER;
932         m->width = width;
933         m->height = height;
934         return MAPS_ERROR_NONE;
935 }
936
937 EXPORT_API int maps_view_object_marker_get_size(const maps_view_object_h marker, int *width, int *height)
938 {
939         if (!maps_condition_check_maps_feature())
940                 return MAPS_ERROR_NOT_SUPPORTED;
941         if (!marker || (!width && !height))
942                 return MAPS_ERROR_INVALID_PARAMETER;
943         maps_view_marker_data_s *m = __get_marker_data(marker);
944         if (!m)
945                 return MAPS_ERROR_INVALID_PARAMETER;
946         if (width)
947                 *width = m->width;
948         if (height)
949                 *height = m->height;
950         return MAPS_ERROR_NONE;
951 }
952
953 int _maps_view_object_marker_set_type(maps_view_object_h marker, maps_view_marker_type_e type)
954 {
955         if (!marker)
956                 return MAPS_ERROR_INVALID_PARAMETER;
957         if ((type < MAPS_VIEW_MARKER_PIN) || (type > MAPS_VIEW_MARKER_STICKER))
958                 return MAPS_ERROR_INVALID_PARAMETER;
959         maps_view_marker_data_s *m = __get_marker_data(marker);
960         if (!m)
961                 return MAPS_ERROR_INVALID_PARAMETER;
962         m->type = type;
963         return MAPS_ERROR_NONE;
964 }
965
966 EXPORT_API int maps_view_object_marker_get_type(const maps_view_object_h marker, maps_view_marker_type_e *type)
967 {
968         if (!maps_condition_check_maps_feature())
969                 return MAPS_ERROR_NOT_SUPPORTED;
970         if (!marker || !type)
971                 return MAPS_ERROR_INVALID_PARAMETER;
972         maps_view_marker_data_s *m = __get_marker_data(marker);
973         if (!m)
974                 return MAPS_ERROR_INVALID_PARAMETER;
975         *type = m->type;
976         return MAPS_ERROR_NONE;
977 }
978
979 EXPORT_API int maps_view_object_marker_set_z_order(maps_view_object_h marker, int z_order)
980 {
981         if (!maps_condition_check_maps_feature())
982                 return MAPS_ERROR_NOT_SUPPORTED;
983         if (!marker || (z_order > 100 || z_order < -100))
984                 return MAPS_ERROR_INVALID_PARAMETER;
985         maps_view_marker_data_s *m = __get_marker_data(marker);
986         if (!m)
987                 return MAPS_ERROR_INVALID_PARAMETER;
988
989         /* Notify view, that the object specific preferences is changed */
990         if (m->z_order != z_order) {
991                 m->z_order = z_order;
992                 _maps_view_on_object_operation(__get_view(marker), marker, MAPS_VIEW_OBJECT_CHANGE);
993         }
994
995         return MAPS_ERROR_NONE;
996 }
997
998 EXPORT_API int maps_view_object_marker_get_z_order(const maps_view_object_h marker,     int *z_order)
999 {
1000         if (!maps_condition_check_maps_feature())
1001                 return MAPS_ERROR_NOT_SUPPORTED;
1002         if (!marker || !z_order)
1003                 return MAPS_ERROR_INVALID_PARAMETER;
1004         maps_view_marker_data_s *m = __get_marker_data(marker);
1005         if (!m)
1006                 return MAPS_ERROR_INVALID_PARAMETER;
1007
1008         *z_order = m->z_order;
1009         return MAPS_ERROR_NONE;
1010 }
1011
1012 int _maps_view_object_overlay_set_type(maps_view_object_h overlay, maps_view_overlay_type_e type)
1013 {
1014         if (!overlay || (type < MAPS_VIEW_OVERLAY_NORMAL || type > MAPS_VIEW_OVERLAY_BOX))
1015                 return MAPS_ERROR_INVALID_PARAMETER;
1016         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1017         if (!m)
1018                 return MAPS_ERROR_INVALID_PARAMETER;
1019         m->type = type;
1020         return MAPS_ERROR_NONE;
1021 }
1022
1023 int _maps_view_object_overlay_get_bubble(maps_view_object_h overlay, Evas_Object **object)
1024 {
1025         if (!overlay || !object)
1026                 return MAPS_ERROR_INVALID_PARAMETER;
1027         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1028         if (!m)
1029                 return MAPS_ERROR_INVALID_PARAMETER;
1030         *object = m->bubble;
1031         return MAPS_ERROR_NONE;
1032 }
1033
1034 int _maps_view_object_overlay_set_bubble(maps_view_object_h overlay)
1035 {
1036         if (!overlay)
1037                 return MAPS_ERROR_INVALID_PARAMETER;
1038         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1039         if (!m)
1040                 return MAPS_ERROR_INVALID_PARAMETER;
1041
1042         int x, y, w, h;
1043         evas_object_geometry_get(m->object, &x, &y, &w, &h);
1044
1045         w += _OVERLAY_BUBBLE_MARGIN * 2;
1046         h += _OVERLAY_BUBBLE_MARGIN * 2 + _OVERLAY_BUBBLE_PIN_SIZE;
1047
1048         m->bubble = evas_object_image_filled_add(evas_object_evas_get(m->object));
1049         evas_object_stack_below(m->bubble, m->object);
1050         evas_object_move(m->bubble, x, y);
1051         evas_object_resize(m->bubble, w, h);
1052         evas_object_show(m->bubble);
1053
1054         unsigned char *pixels;
1055         int row_stride;
1056         cairo_t *cairo;
1057         cairo_surface_t *surface;
1058
1059         evas_object_image_alpha_set(m->bubble, EINA_TRUE);
1060         evas_object_image_colorspace_set(m->bubble, EVAS_COLORSPACE_ARGB8888);
1061         evas_object_image_size_set(m->bubble, w, h);
1062         evas_object_image_fill_set(m->bubble, 0, 0, w, h);
1063
1064         pixels = (unsigned char *)evas_object_image_data_get(m->bubble, EINA_TRUE);
1065         row_stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w);
1066         surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32,
1067                                                                                                    w, h, row_stride);
1068         /* Create the cairo context */
1069         cairo = cairo_create(surface);
1070
1071         /* Configuration */
1072         cairo_set_source_rgba(cairo, 0, 0, 0, 0);
1073         cairo_paint_with_alpha(cairo, 0);
1074
1075         /* set the size of bubble */
1076         int bx = x + 2;
1077         int by = y + 2;
1078         int bw = w - bx * 2;
1079         int bh = h - by - _OVERLAY_BUBBLE_PIN_SIZE;
1080
1081         /* build a path */
1082         cairo_new_path(cairo);
1083         if (m->type == MAPS_VIEW_OVERLAY_BUBBLE) {
1084                 double r = bh / 8.;
1085                 double d = M_PI / 180.;
1086                 cairo_arc(cairo, bx + bw - r, by + r, r, -90 * d, 0 * d);
1087                 cairo_arc(cairo, bx + bw - r, by + bh - r, r, 0 * d, 90 * d);
1088                 cairo_line_to(cairo, bx + bw / 2 + _OVERLAY_BUBBLE_PIN_SIZE, by + bh);
1089                 cairo_line_to(cairo, bx + bw / 2, by + bh + _OVERLAY_BUBBLE_PIN_SIZE);
1090                 cairo_line_to(cairo, bx + bw / 2 - _OVERLAY_BUBBLE_PIN_SIZE, by + bh);
1091                 cairo_arc(cairo, bx + r, by + bh - r, r, 90 * d, 180 * d);
1092                 cairo_arc(cairo, bx + r, by + r, r, 180 * d, 270 * d);
1093         } else {
1094                 cairo_move_to(cairo, 1., 1.);
1095                 cairo_line_to(cairo, 1., bh);
1096                 cairo_line_to(cairo, bw / 2 - _OVERLAY_BUBBLE_PIN_SIZE, bh);
1097                 cairo_line_to(cairo, bw / 2, bh + _OVERLAY_BUBBLE_PIN_SIZE);
1098                 cairo_line_to(cairo, bw / 2 + _OVERLAY_BUBBLE_PIN_SIZE, bh);
1099                 cairo_line_to(cairo, bw, bh);
1100                 cairo_line_to(cairo, bw, 1);
1101         }
1102         cairo_close_path(cairo);
1103
1104         /* clipping */
1105         cairo_clip_preserve(cairo);
1106         cairo_set_source_rgb(cairo, 1., 1., 1.);
1107         cairo_fill_preserve(cairo);
1108         cairo_set_source_rgb(cairo, .1, .1, .1);
1109         cairo_set_line_width(cairo, 3);
1110
1111
1112         cairo_stroke(cairo);
1113         cairo_destroy(cairo);
1114         cairo_surface_destroy(surface);
1115
1116         evas_object_image_data_set(m->bubble, pixels);
1117         evas_object_image_data_update_add(m->bubble, 0, 0, w, h);
1118
1119         return MAPS_ERROR_NONE;
1120 }
1121
1122 EXPORT_API int maps_view_object_overlay_get_object(maps_view_object_h overlay, Evas_Object **object)
1123 {
1124         if (!maps_condition_check_maps_feature())
1125                 return MAPS_ERROR_NOT_SUPPORTED;
1126         if (!overlay || !object)
1127                 return MAPS_ERROR_INVALID_PARAMETER;
1128         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1129         if (!m)
1130                 return MAPS_ERROR_INVALID_PARAMETER;
1131         *object = m->object;
1132         return MAPS_ERROR_NONE;
1133 }
1134
1135 int _maps_view_object_overlay_set_object(maps_view_object_h overlay, Evas_Object *object)
1136 {
1137         if (!overlay || !object)
1138                 return MAPS_ERROR_INVALID_PARAMETER;
1139         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1140         if (!m)
1141                 return MAPS_ERROR_INVALID_PARAMETER;
1142         m->object = object;
1143         if (m->type != MAPS_VIEW_OVERLAY_NORMAL)
1144                 _maps_view_object_overlay_set_bubble(overlay);
1145
1146         return MAPS_ERROR_NONE;
1147 }
1148
1149 EXPORT_API int maps_view_object_overlay_set_coordinates(maps_view_object_h overlay, maps_coordinates_h coordinates)
1150 {
1151         if (!maps_condition_check_maps_feature())
1152                 return MAPS_ERROR_NOT_SUPPORTED;
1153         if (!overlay || !coordinates)
1154                 return MAPS_ERROR_INVALID_PARAMETER;
1155         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1156         if (!m)
1157                 return MAPS_ERROR_INVALID_PARAMETER;
1158         if (m->coordinates)
1159                 maps_coordinates_destroy(m->coordinates);
1160         m->coordinates = coordinates;
1161
1162         /* Notify view, that the object specific preferences is changed */
1163         _maps_view_on_object_operation(__get_view(overlay), overlay, MAPS_VIEW_OBJECT_CHANGE);
1164
1165         return MAPS_ERROR_NONE;
1166 }
1167
1168 EXPORT_API int maps_view_object_overlay_get_coordinates(const maps_view_object_h overlay, maps_coordinates_h *coordinates)
1169 {
1170         if (!maps_condition_check_maps_feature())
1171                 return MAPS_ERROR_NOT_SUPPORTED;
1172         if (!overlay || !coordinates)
1173                 return MAPS_ERROR_INVALID_PARAMETER;
1174         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1175         if (!m)
1176                 return MAPS_ERROR_INVALID_PARAMETER;
1177         return maps_coordinates_clone(m->coordinates, coordinates);
1178 }
1179
1180 EXPORT_API int maps_view_object_overlay_set_min_zoom_level(maps_view_object_h overlay, int zoom)
1181 {
1182         if (!maps_condition_check_maps_feature())
1183                 return MAPS_ERROR_NOT_SUPPORTED;
1184         if (!overlay || zoom < 0)
1185                 return MAPS_ERROR_INVALID_PARAMETER;
1186         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1187         if (!m)
1188                 return MAPS_ERROR_INVALID_PARAMETER;
1189         int map_min_zoom_level = 0;
1190         maps_view_get_min_zoom_level(__get_view(overlay), &map_min_zoom_level);
1191         if (zoom < map_min_zoom_level)
1192                 m->min_zoom_level = map_min_zoom_level;
1193         else
1194                 m->min_zoom_level = zoom;
1195         return MAPS_ERROR_NONE;
1196 }
1197
1198 EXPORT_API int maps_view_object_overlay_get_max_zoom_level(const maps_view_object_h overlay, int *zoom)
1199 {
1200         if (!maps_condition_check_maps_feature())
1201                 return MAPS_ERROR_NOT_SUPPORTED;
1202         if (!overlay || !zoom)
1203                 return MAPS_ERROR_INVALID_PARAMETER;
1204         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1205         if (!m)
1206                 return MAPS_ERROR_INVALID_PARAMETER;
1207         *zoom = m->max_zoom_level;
1208         return MAPS_ERROR_NONE;
1209 }
1210
1211 EXPORT_API int maps_view_object_overlay_set_max_zoom_level(maps_view_object_h overlay, int zoom)
1212 {
1213         if (!maps_condition_check_maps_feature())
1214                 return MAPS_ERROR_NOT_SUPPORTED;
1215         if (!overlay || zoom < 0)
1216                 return MAPS_ERROR_INVALID_PARAMETER;
1217         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1218         if (!m)
1219                 return MAPS_ERROR_INVALID_PARAMETER;
1220         int map_max_zoom_level = 0;
1221         maps_view_get_max_zoom_level(__get_view(overlay), &map_max_zoom_level);
1222         if (zoom < map_max_zoom_level)
1223                 m->max_zoom_level = map_max_zoom_level;
1224         else
1225                 m->max_zoom_level = zoom;
1226         return MAPS_ERROR_NONE;
1227 }
1228
1229 EXPORT_API int maps_view_object_overlay_get_min_zoom_level(const maps_view_object_h overlay, int *zoom)
1230 {
1231         if (!maps_condition_check_maps_feature())
1232                 return MAPS_ERROR_NOT_SUPPORTED;
1233         if (!overlay || !zoom)
1234                 return MAPS_ERROR_INVALID_PARAMETER;
1235         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1236         if (!m)
1237                 return MAPS_ERROR_INVALID_PARAMETER;
1238         *zoom = m->min_zoom_level;
1239         return MAPS_ERROR_NONE;
1240 }
1241
1242 static bool __maps_view_object_overlay_set_visible(maps_view_object_h overlay)
1243 {
1244         if (!overlay)
1245                 return false;
1246
1247         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1248         if (!m)
1249                 return false;
1250
1251         maps_view_object_s *o = (maps_view_object_s *)overlay;
1252         if (o->visible) {
1253                 int zoom;
1254                 maps_view_get_zoom_level(__get_view(overlay), &zoom);
1255                 if (zoom < m->min_zoom_level || zoom > m->max_zoom_level) {
1256                         evas_object_hide(m->object);
1257                         if (m->bubble)
1258                                 evas_object_hide(m->bubble);
1259                 } else {
1260                         evas_object_show(m->object);
1261                         if (m->bubble)
1262                                 evas_object_show(m->bubble);
1263                 }
1264         } else {
1265                 evas_object_hide(m->object);
1266                 if (m->bubble)
1267                         evas_object_hide(m->bubble);
1268         }
1269         return true;
1270 }
1271
1272 static bool __maps_view_object_overlay_clip(maps_view_object_h overlay, Evas_Object *clipper)
1273 {
1274         if (!overlay || !clipper)
1275                 return false;
1276
1277         int x, y, w, h;
1278         maps_view_get_screen_location(__get_view(overlay), &x, &y, &w, &h);
1279         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1280         if (!m)
1281                 return false;
1282         evas_object_color_set(clipper, 255, 255, 255, 255);
1283         evas_object_move(clipper, x, y);
1284         evas_object_resize(clipper, w, h);
1285         evas_object_clip_set(m->object, clipper);
1286         if (m->bubble)
1287                 evas_object_clip_set(m->bubble, clipper);
1288         evas_object_show(clipper);
1289
1290         m->clipper = clipper;
1291         return true;
1292 }
1293
1294 static bool __maps_view_object_overlay_move(maps_view_object_h overlay, maps_coordinates_h coordinates)
1295 {
1296         if (!overlay || !coordinates)
1297                 return false;
1298
1299         int x, y, w, h;
1300         maps_view_geolocation_to_screen(__get_view(overlay), coordinates, &x, &y);
1301         maps_view_overlay_data_s *m = __get_overlay_data(overlay);
1302         if (!m)
1303                 return false;
1304         evas_object_geometry_get(m->object, NULL, NULL, &w, &h);
1305
1306         x -= w / 2;
1307         y -= h;
1308
1309         if (m->type != MAPS_VIEW_OVERLAY_NORMAL) {
1310                 y -= _OVERLAY_BUBBLE_MARGIN + _OVERLAY_BUBBLE_PIN_SIZE;
1311                 evas_object_move(m->object, x, y);
1312
1313                 if (m->bubble) {
1314                         x -= _OVERLAY_BUBBLE_MARGIN;
1315                         y -= _OVERLAY_BUBBLE_MARGIN ;
1316                         evas_object_move(m->bubble, x, y);
1317                 }
1318         } else {
1319                 evas_object_move(m->object, x, y);
1320         }
1321         return true;
1322 }
1323
1324 static bool __maps_view_object_overlay_update(maps_view_object_h overlay, Evas_Object *clipper)
1325 {
1326         if (!overlay || !clipper)
1327                 return false;
1328
1329         bool ret = false;
1330         maps_coordinates_h coordinates = NULL;
1331
1332         do {
1333                 ret = __maps_view_object_overlay_set_visible(overlay);
1334                 if (!ret) break;
1335
1336                 ret = __maps_view_object_overlay_clip(overlay, clipper);
1337                 if (!ret) break;
1338
1339                 maps_view_object_overlay_get_coordinates(overlay, &coordinates);
1340                 ret = __maps_view_object_overlay_move(overlay, coordinates);
1341         } while (0);
1342
1343         if (coordinates)
1344                 maps_coordinates_destroy(coordinates);
1345
1346         return ret;
1347 }
1348
1349 bool _maps_view_object_overlay_cb(int index, int total, maps_view_object_h object, void *user_data)
1350 {
1351         if (!object || !user_data)
1352                 return false;
1353
1354         maps_view_object_type_e type;
1355         maps_view_object_get_type(object, &type);
1356         if (type != MAPS_VIEW_OBJECT_OVERLAY)
1357                 return true;
1358         return __maps_view_object_overlay_update(object, (Evas_Object*)user_data);
1359 }
1360
1361 int _maps_view_object_overlay_operation(maps_view_h view, maps_view_object_h object, maps_view_object_operation_e operation)
1362 {
1363         if (!view || !object)
1364                 return MAPS_ERROR_INVALID_PARAMETER;
1365
1366         Evas_Object *parent = NULL, *clipper = NULL;
1367         maps_view_overlay_data_s *o = __get_overlay_data(object);
1368
1369         if (!o)
1370                 return MAPS_ERROR_INVALID_PARAMETER;
1371
1372         if (operation == MAPS_VIEW_OBJECT_ADD) {
1373                 _maps_view_get_parent(view, &parent);
1374                 evas_object_smart_member_add(o->bubble, parent);
1375                 evas_object_smart_member_add(o->object, parent);
1376         }
1377
1378         if (operation != MAPS_VIEW_OBJECT_REMOVE) {
1379                 _maps_view_get_clipper(view, &clipper);
1380                 __maps_view_object_overlay_update(object, clipper);
1381         }
1382
1383         return MAPS_ERROR_NONE;
1384 }