summaryrefslogtreecommitdiff
path: root/legacy/elementary
diff options
context:
space:
mode:
authorBluezery <ohpowel@gmail.com>2012-03-22 10:40:04 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-22 10:40:04 +0000
commit9e3b73137bf83e3cb2b62a03c6275e40ffd120c5 (patch)
treeb159a54584e83bee277af2f505c86c8a90db0e3f /legacy/elementary
parent047fcff3c303dbf1abdf28a6c96d41720e9cc7cf (diff)
From: Bluezery <ohpowel@gmail.com>
Subject: [E-devel] [Patch][elm_map] Add line, polygon, circle, scale overlay This patch adds new overlay APIs (line, polygon, circle, scale) for elm_map. These overlays are adhered to map even though zooming, panning. You can test these by doing "elementary_test --> click mouse right --> overlay" SVN revision: 69562
Diffstat (limited to 'legacy/elementary')
-rw-r--r--legacy/elementary/data/themes/map_circle.pngbin0 -> 28715 bytes
-rw-r--r--legacy/elementary/data/themes/map_scale.pngbin0 -> 244 bytes
-rw-r--r--legacy/elementary/data/themes/widgets/map.edc57
-rw-r--r--legacy/elementary/src/bin/test_map.c317
-rw-r--r--legacy/elementary/src/lib/elm_map.c509
-rw-r--r--legacy/elementary/src/lib/elm_map.h126
6 files changed, 891 insertions, 118 deletions
diff --git a/legacy/elementary/data/themes/map_circle.png b/legacy/elementary/data/themes/map_circle.png
new file mode 100644
index 0000000000..1641097cb9
--- /dev/null
+++ b/legacy/elementary/data/themes/map_circle.png
Binary files differ
diff --git a/legacy/elementary/data/themes/map_scale.png b/legacy/elementary/data/themes/map_scale.png
new file mode 100644
index 0000000000..ff7be49ed4
--- /dev/null
+++ b/legacy/elementary/data/themes/map_scale.png
Binary files differ
diff --git a/legacy/elementary/data/themes/widgets/map.edc b/legacy/elementary/data/themes/widgets/map.edc
index c4711c4ba5..2d7b177079 100644
--- a/legacy/elementary/data/themes/widgets/map.edc
+++ b/legacy/elementary/data/themes/widgets/map.edc
@@ -742,4 +742,59 @@ group { name: "elm/map/marker_bubble/default";
742 } 742 }
743 } 743 }
744} 744}
745 745group { name: "elm/map/circle/base/default";
746 images {
747 image: "map_circle.png" COMP;
748 }
749 parts {
750 part { name: "base";
751 ignore_flags: ON_HOLD;
752 description { state: "default" 0.0;
753 image.normal: "map_circle.png";
754 }
755 }
756 }
757}
758group { name: "elm/map/scale/base/default";
759 data {
760 item: size_w 100;
761 item: size_h 25;
762 }
763 images {
764 image: "map_scale.png" COMP;
765 }
766 parts {
767 part { name: "base";
768 ignore_flags: ON_HOLD;
769 description { state: "default" 0.0;
770 image.normal: "map_scale.png";
771 image.border: 10 10 10 10;
772 }
773 }
774 part { name: "elm.text";
775 type: TEXT;
776 ignore_flags: ON_HOLD;
777 effect: SOFT_SHADOW;
778 mouse_events: 0;
779 scale: 1;
780 description { state: "default" 0.0;
781 color: 224 224 224 255;
782 color3: 0 0 0 64;
783 rel1 {
784 relative: 0 0;
785 offset: 1 1;
786 }
787 rel2 {
788 relative: 1 1;
789 offset: -1 -1;
790 }
791 text {
792 font: "Sans,Edje-Vera";
793 size: 10;
794 min: 0 0;
795 align: 0.1 0.5;
796 }
797 }
798 }
799 }
800}
diff --git a/legacy/elementary/src/bin/test_map.c b/legacy/elementary/src/bin/test_map.c
index 5ed2f8d733..bf1b0d2fed 100644
--- a/legacy/elementary/src/bin/test_map.c
+++ b/legacy/elementary/src/bin/test_map.c
@@ -38,6 +38,11 @@ static Elm_Map_Overlay *route_start, *route_end, *route_clas;
38static Elm_Map_Overlay *bubble_img; 38static Elm_Map_Overlay *bubble_img;
39static Elm_Map_Overlay *bubble_parking; 39static Elm_Map_Overlay *bubble_parking;
40static Elm_Map_Overlay *route_ovl; 40static Elm_Map_Overlay *route_ovl;
41static Elm_Map_Overlay *line_start, *line_end, *line;
42static Elm_Map_Overlay *poly;
43static Elm_Map_Overlay *circle;
44static Elm_Map_Overlay *scale;
45static Eina_List *poly_points;
41 46
42static Evas_Object *menu, *fs_win; 47static Evas_Object *menu, *fs_win;
43static Elm_Map_Route *route; 48static Elm_Map_Route *route;
@@ -81,6 +86,109 @@ _route_icon_get(Evas_Object *obj)
81 return icon; 86 return icon;
82} 87}
83 88
89static Evas_Object *
90_box_get(Evas_Object *obj, Overlay_Data *data, Elm_Map_Overlay *ovl)
91{
92 Evas_Object *bx, *img, *label;
93 double lon, lat;
94 char buf[256];
95 bx = elm_box_add(obj);
96 evas_object_show(bx);
97
98 img = evas_object_image_add(evas_object_evas_get(obj));
99 evas_object_image_file_set(img, data->file, NULL);
100 evas_object_image_filled_set(img, EINA_TRUE);
101 evas_object_size_hint_min_set(img, 64, 64);
102 evas_object_show(img);
103 elm_box_pack_end(bx, img);
104
105 label = elm_label_add(bx);
106 elm_map_overlay_region_get(ovl, &lon, &lat);
107 snprintf(buf, sizeof(buf), "%0.4lf %0.4lf", lon, lat);
108 elm_object_text_set(label, buf);
109 evas_object_show(label);
110 elm_box_pack_end(bx, label);
111 return bx;
112}
113
114static Evas_Object *
115_label_get(Evas_Object *obj)
116{
117 Evas_Object *label;
118 label = elm_label_add(obj);
119 elm_object_text_set(label, "Here is a parking lot.");
120 return label;
121}
122
123static Evas_Object *
124_icon_get(Evas_Object *obj, Overlay_Data *data)
125{
126 Evas_Object *icon = elm_icon_add(obj);
127 elm_icon_file_set(icon, data->file, NULL);
128 evas_object_show(icon);
129
130 return icon;
131}
132
133static void
134_overlay_hide(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
135{
136 elm_map_overlay_hide_set(data, EINA_TRUE);
137}
138
139static void
140_overlay_pause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
141{
142 elm_map_overlay_paused_set(data, EINA_TRUE);
143}
144
145static void
146_overlay_unpause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
147{
148 elm_map_overlay_paused_set(data, EINA_FALSE);
149}
150
151static void
152_overlay_show(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
153{
154 elm_map_overlay_show(data);
155}
156
157static Evas_Object *
158_btn_box_get(Evas_Object *obj, Elm_Map_Overlay *ovl)
159{
160 Evas_Object *bx, *btn, *btn2, *btn3, *btn4;
161 bx = elm_box_add(obj);
162 elm_box_horizontal_set(bx, EINA_TRUE);
163 evas_object_show(bx);
164
165 btn = elm_button_add(bx);
166 elm_object_text_set(btn, "Hide");
167 evas_object_smart_callback_add(btn, "clicked", _overlay_hide, ovl);
168 evas_object_show(btn);
169 elm_box_pack_end(bx, btn);
170
171 btn2 = elm_button_add(bx);
172 elm_object_text_set(btn2, "Pause");
173 evas_object_smart_callback_add(btn2, "clicked", _overlay_pause, ovl);
174 evas_object_show(btn2);
175 elm_box_pack_end(bx, btn2);
176
177 btn3 = elm_button_add(bx);
178 elm_object_text_set(btn3, "Unpause");
179 evas_object_smart_callback_add(btn3, "clicked", _overlay_unpause, ovl);
180 evas_object_show(btn3);
181 elm_box_pack_end(bx, btn3);
182
183 btn4 = elm_button_add(bx);
184 elm_object_text_set(btn4, "Show");
185 evas_object_smart_callback_add(btn4, "clicked", _overlay_show, ovl);
186 evas_object_show(btn4);
187 elm_box_pack_end(bx, btn4);
188
189 return bx;
190}
191
84static void 192static void
85_bubble_parking_follow(Evas_Object *map) 193_bubble_parking_follow(Evas_Object *map)
86{ 194{
@@ -316,7 +424,16 @@ _map_name_loaded_fail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
316} 424}
317 425
318static void 426static void
319map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 427_src_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
428{
429 Map_Source *s = data;
430
431 if (!s) return;
432 elm_map_source_set(s->map, s->type, s->source_name);
433}
434
435static void
436_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
320{ 437{
321 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); 438 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
322 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12); 439 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12);
@@ -324,7 +441,7 @@ map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUS
324} 441}
325 442
326static void 443static void
327map_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 444_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
328{ 445{
329 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); 446 elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
330 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12); 447 if (elm_map_zoom_get(data) < 12) elm_map_zoom_set(data, 12);
@@ -504,115 +621,74 @@ _zoom_max_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED
504} 621}
505 622
506static void 623static void
507src_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 624_line_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
508{
509 Map_Source *s = data;
510
511 if (!s) return;
512 elm_map_source_set(s->map, s->type, s->source_name);
513}
514
515static Evas_Object *
516_box_get(Evas_Object *obj, Overlay_Data *data, Elm_Map_Overlay *ovl)
517{ 625{
518 Evas_Object *bx, *img, *label;
519 double lon, lat; 626 double lon, lat;
520 char buf[256];
521 bx = elm_box_add(obj);
522 evas_object_show(bx);
523 627
524 img = evas_object_image_add(evas_object_evas_get(obj)); 628 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
525 evas_object_image_file_set(img, data->file, NULL); 629 printf("line marker: %d %d %lf %lf\n", down_x, down_y, lon, lat);
526 evas_object_image_filled_set(img, EINA_TRUE); 630 if (line_start && line_end)
527 evas_object_size_hint_min_set(img, 64, 64); 631 {
528 evas_object_show(img); 632 elm_map_overlay_del(line_start);
529 elm_box_pack_end(bx, img); 633 elm_map_overlay_del(line_end);
634 elm_map_overlay_del(line);
635 line_start = NULL;
636 line_end = NULL;
637 line = NULL;
638 }
639 if (!line_start) line_start = elm_map_overlay_add(data, lon, lat);
640 else if (!line_end) line_end = elm_map_overlay_add(data, lon, lat);
530 641
531 label = elm_label_add(bx); 642 if (line_start && line_end)
532 elm_map_overlay_region_get(ovl, &lon, &lat); 643 {
533 snprintf(buf, sizeof(buf), "%0.4lf %0.4lf", lon, lat); 644 double flon, flat, tlon, tlat;
534 elm_object_text_set(label, buf); 645 elm_map_overlay_region_get(line_start, &flon, &flat);
535 evas_object_show(label); 646 elm_map_overlay_region_get(line_end, &tlon, &tlat);
536 elm_box_pack_end(bx, label); 647 line = elm_map_overlay_line_add(data, flon, flat, tlon, tlat);
537 return bx; 648 printf("line add: (%lf, %lf) --> (%lf, %lf)\n", flon, flat, tlon, tlat);
649 }
538} 650}
539 651
540static void 652static void
541_overlay_hide(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 653_poly_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
542{ 654{
543 elm_map_overlay_hide_set(data, EINA_TRUE); 655 double lon, lat;
544}
545 656
546static void 657 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
547_overlay_pause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 658 printf("%d %d %lf %lf\n", down_x, down_y, lon, lat);
548{
549 elm_map_overlay_paused_set(data, EINA_TRUE);
550}
551 659
552static void 660 if (!poly) poly = elm_map_overlay_polygon_add(data);
553_overlay_unpause(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 661 poly_points = eina_list_append(poly_points,
554{ 662 elm_map_overlay_add(data, lon, lat));
555 elm_map_overlay_paused_set(data, EINA_FALSE); 663 elm_map_overlay_polygon_region_add(poly, lon, lat);
556} 664}
557 665
558static void 666static void
559_overlay_show(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) 667_poly_clear(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
560{ 668{
561 elm_map_overlay_show(data); 669 Elm_Map_Overlay *ovl;
670 if (poly) elm_map_overlay_del(poly);
671 EINA_LIST_FREE(poly_points, ovl) elm_map_overlay_del(ovl);
672 poly = NULL;
673 poly_points = NULL;
562} 674}
563 675
564static Evas_Object * 676static void
565_btn_box_get(Evas_Object *obj, Elm_Map_Overlay *ovl) 677_circle_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
566{ 678{
567 Evas_Object *bx, *btn, *btn2, *btn3, *btn4; 679 double radius = 100;
568 bx = elm_box_add(obj); 680 double lon, lat;
569 elm_box_horizontal_set(bx, EINA_TRUE);
570 evas_object_show(bx);
571
572 btn = elm_button_add(bx);
573 elm_object_text_set(btn, "Hide");
574 evas_object_smart_callback_add(btn, "clicked", _overlay_hide, ovl);
575 evas_object_show(btn);
576 elm_box_pack_end(bx, btn);
577
578 btn2 = elm_button_add(bx);
579 elm_object_text_set(btn2, "Pause");
580 evas_object_smart_callback_add(btn2, "clicked", _overlay_pause, ovl);
581 evas_object_show(btn2);
582 elm_box_pack_end(bx, btn2);
583
584 btn3 = elm_button_add(bx);
585 elm_object_text_set(btn3, "Unpause");
586 evas_object_smart_callback_add(btn3, "clicked", _overlay_unpause, ovl);
587 evas_object_show(btn3);
588 elm_box_pack_end(bx, btn3);
589
590 btn4 = elm_button_add(bx);
591 elm_object_text_set(btn4, "Show");
592 evas_object_smart_callback_add(btn4, "clicked", _overlay_show, ovl);
593 evas_object_show(btn4);
594 elm_box_pack_end(bx, btn4);
595
596 return bx;
597}
598 681
599static Evas_Object * 682 if (circle) elm_map_overlay_del(circle);
600_label_get(Evas_Object *obj) 683 elm_map_canvas_to_region_convert(data, down_x, down_y, &lon, &lat);
601{ 684 circle = elm_map_overlay_circle_add(data, lon, lat, radius);
602 Evas_Object *label;
603 label = elm_label_add(obj);
604 elm_object_text_set(label, "Here is a parking lot.");
605 return label;
606} 685}
607 686
608static Evas_Object * 687static void
609_icon_get(Evas_Object *obj, Overlay_Data *data) 688_scale_add(void *data, Evas_Object *obj __UNUSED__, void *ei __UNUSED__)
610{ 689{
611 Evas_Object *icon = elm_icon_add(obj); 690 if (scale) elm_map_overlay_del(scale);
612 elm_icon_file_set(icon, data->file, NULL); 691 scale = elm_map_overlay_scale_add(data, down_x, down_y);
613 evas_object_show(icon);
614
615 return icon;
616} 692}
617 693
618static void 694static void
@@ -635,7 +711,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
635 ts[idx].map = data; 711 ts[idx].map = data;
636 ts[idx].type = ELM_MAP_SOURCE_TYPE_TILE; 712 ts[idx].type = ELM_MAP_SOURCE_TYPE_TILE;
637 ts[idx].source_name = strdup(tile_srcs[idx]); 713 ts[idx].source_name = strdup(tile_srcs[idx]);
638 elm_menu_item_add(menu, parent, "", tile_srcs[idx], src_set, &ts[idx]); 714 elm_menu_item_add(menu, parent, "", tile_srcs[idx], _src_set, &ts[idx]);
639 } 715 }
640 for (idx = 0; route_srcs[idx]; idx++) 716 for (idx = 0; route_srcs[idx]; idx++)
641 { 717 {
@@ -643,7 +719,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
643 rs[idx].map = data; 719 rs[idx].map = data;
644 rs[idx].type = ELM_MAP_SOURCE_TYPE_ROUTE; 720 rs[idx].type = ELM_MAP_SOURCE_TYPE_ROUTE;
645 rs[idx].source_name = strdup(route_srcs[idx]); 721 rs[idx].source_name = strdup(route_srcs[idx]);
646 elm_menu_item_add(menu, parent, "", route_srcs[idx], src_set, &rs[idx]); 722 elm_menu_item_add(menu, parent, "", route_srcs[idx], _src_set, &rs[idx]);
647 } 723 }
648 for (idx = 0; name_srcs[idx]; idx++) 724 for (idx = 0; name_srcs[idx]; idx++)
649 { 725 {
@@ -651,7 +727,7 @@ _submenu_src_add(void *data, Elm_Object_Item *parent)
651 ns[idx].map = data; 727 ns[idx].map = data;
652 ns[idx].type = ELM_MAP_SOURCE_TYPE_NAME; 728 ns[idx].type = ELM_MAP_SOURCE_TYPE_NAME;
653 ns[idx].source_name = strdup(name_srcs[idx]); 729 ns[idx].source_name = strdup(name_srcs[idx]);
654 elm_menu_item_add(menu, parent, "", name_srcs[idx], src_set, &ns[idx]); 730 elm_menu_item_add(menu, parent, "", name_srcs[idx], _src_set, &ns[idx]);
655 } 731 }
656} 732}
657 733
@@ -659,8 +735,8 @@ static void
659_submenu_move_add(void *data, Elm_Object_Item *parent) 735_submenu_move_add(void *data, Elm_Object_Item *parent)
660{ 736{
661 if ((!data) || (!parent)) return; 737 if ((!data) || (!parent)) return;
662 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", map_show_urmatt, data); 738 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", _show_urmatt, data);
663 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", map_bring_seoul, data); 739 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", _bring_seoul, data);
664 740
665} 741}
666 742
@@ -699,6 +775,17 @@ _submenu_track_add(void *data, Elm_Object_Item *parent)
699} 775}
700 776
701static void 777static void
778_submenu_ovl_add(void *data, Elm_Object_Item *parent)
779{
780 if ((!data) || (!parent)) return;
781 elm_menu_item_add(menu, parent, NULL, "Add line", _line_add, data);
782 elm_menu_item_add(menu, parent, NULL, "Add polygon", _poly_add, data);
783 elm_menu_item_add(menu, parent, NULL, "Clear polygon", _poly_clear, data);
784 elm_menu_item_add(menu, parent, NULL, "Add circle", _circle_add, data);
785 elm_menu_item_add(menu, parent, NULL, "Add scale", _scale_add, data);
786}
787
788static void
702_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) 789_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
703{ 790{
704 Evas_Event_Mouse_Down *down = event_info; 791 Evas_Event_Mouse_Down *down = event_info;
@@ -726,9 +813,11 @@ _map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event
726 _submenu_prop_add(data, menu_it); 813 _submenu_prop_add(data, menu_it);
727 menu_it = elm_menu_item_add(menu, NULL, "", "Track", NULL, NULL); 814 menu_it = elm_menu_item_add(menu, NULL, "", "Track", NULL, NULL);
728 _submenu_track_add(data, menu_it); 815 _submenu_track_add(data, menu_it);
816 menu_it = elm_menu_item_add(menu, NULL, "", "Overlay", NULL, NULL);
817 _submenu_ovl_add(data, menu_it);
729 818
730 elm_menu_move(menu, down->canvas.x, down->canvas.y); 819 elm_menu_move(menu, down->canvas.x, down->canvas.y);
731 evas_object_show(menu); 820 evas_object_show(menu);
732 } 821 }
733} 822}
734 823
@@ -791,25 +880,41 @@ _overlay_cb(void *data __UNUSED__, Evas_Object *map, void *ev)
791 Overlay_Data *od; 880 Overlay_Data *od;
792 Elm_Map_Overlay_Type type = elm_map_overlay_type_get(overlay); 881 Elm_Map_Overlay_Type type = elm_map_overlay_type_get(overlay);
793 882
794 if (type != ELM_MAP_OVERLAY_TYPE_DEFAULT) return; 883 if (type != ELM_MAP_OVERLAY_TYPE_GROUP &&
884 type != ELM_MAP_OVERLAY_TYPE_DEFAULT) return;
795 885
796 if (!bubble_img) bubble_img = elm_map_overlay_bubble_add(map); 886 if (!bubble_img) bubble_img = elm_map_overlay_bubble_add(map);
797 elm_map_overlay_bubble_follow(bubble_img, overlay); 887 elm_map_overlay_bubble_follow(bubble_img, overlay);
798 elm_map_overlay_bubble_content_clear(bubble_img); 888 elm_map_overlay_bubble_content_clear(bubble_img);
799 889
800 od = elm_map_overlay_data_get(overlay); 890 if (type == ELM_MAP_OVERLAY_TYPE_GROUP)
801 if (od) 891 {
802 elm_map_overlay_bubble_content_append(bubble_img, 892 Eina_List *l;
803 _box_get(map, od, overlay)); 893 Elm_Map_Overlay *memb;
804 elm_map_overlay_bubble_content_append(bubble_img, 894 Eina_List *members = elm_map_overlay_group_members_get(overlay);
805 _btn_box_get(map, overlay)); 895 printf("Group Members Num: %d\n", eina_list_count(members));
896 EINA_LIST_FOREACH(members, l, memb)
897 {
898 od = elm_map_overlay_data_get(memb);
899 if (od)
900 elm_map_overlay_bubble_content_append(bubble_img,
901 _box_get(map, od, memb));
902 }
903 }
904 else
905 {
906 od = elm_map_overlay_data_get(overlay);
907 if (od)
908 elm_map_overlay_bubble_content_append(bubble_img,
909 _box_get(map, od, overlay));
910 elm_map_overlay_bubble_content_append(bubble_img,
911 _btn_box_get(map, overlay));
912 }
806} 913}
807 914
808static void 915static void
809_parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl) 916_parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl)
810{ 917{
811 if (elm_map_overlay_type_get(ovl) != ELM_MAP_OVERLAY_TYPE_DEFAULT) return;
812
813 double lon, lat; 918 double lon, lat;
814 Evas_Coord x, y; 919 Evas_Coord x, y;
815 elm_map_overlay_region_get(ovl, &lon, &lat); 920 elm_map_overlay_region_get(ovl, &lon, &lat);
diff --git a/legacy/elementary/src/lib/elm_map.c b/legacy/elementary/src/lib/elm_map.c
index 78f598a2ca..442cc3b22a 100644
--- a/legacy/elementary/src/lib/elm_map.c
+++ b/legacy/elementary/src/lib/elm_map.c
@@ -13,6 +13,7 @@
13typedef struct _Widget_Data Widget_Data; 13typedef struct _Widget_Data Widget_Data;
14typedef struct _Path Path; 14typedef struct _Path Path;
15typedef struct _Color Color; 15typedef struct _Color Color;
16typedef struct _Region Region;
16typedef struct _Pan Pan; 17typedef struct _Pan Pan;
17typedef struct _Grid Grid; 18typedef struct _Grid Grid;
18typedef struct _Grid_Item Grid_Item; 19typedef struct _Grid_Item Grid_Item;
@@ -21,6 +22,10 @@ typedef struct _Overlay_Class Overlay_Class;
21typedef struct _Overlay_Group Overlay_Group; 22typedef struct _Overlay_Group Overlay_Group;
22typedef struct _Overlay_Bubble Overlay_Bubble; 23typedef struct _Overlay_Bubble Overlay_Bubble;
23typedef struct _Overlay_Route Overlay_Route; 24typedef struct _Overlay_Route Overlay_Route;
25typedef struct _Overlay_Line Overlay_Line;
26typedef struct _Overlay_Polygon Overlay_Polygon;
27typedef struct _Overlay_Circle Overlay_Circle;
28typedef struct _Overlay_Scale Overlay_Scale;
24typedef struct _Marker_Group Marker_Group; 29typedef struct _Marker_Group Marker_Group;
25typedef struct _Marker_Bubble Marker_Bubble; 30typedef struct _Marker_Bubble Marker_Bubble;
26typedef struct _Path_Node Path_Node; 31typedef struct _Path_Node Path_Node;
@@ -38,6 +43,7 @@ typedef int (*Elm_Map_Module_Tile_Zoom_Max_Func)(void);
38typedef char *(*Elm_Map_Module_Tile_Url_Func)(const Evas_Object *obj, int x, int y, int zoom); 43typedef char *(*Elm_Map_Module_Tile_Url_Func)(const Evas_Object *obj, int x, int y, int zoom);
39typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y); 44typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
40typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat); 45typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
46typedef double (*Elm_Map_Module_Tile_Scale_Func)(const Evas_Object *obj, double lon, double lat, int zoom);
41typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *obj, const char *type_name, int method, double flon, double flat, double tlon, double tlat); 47typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *obj, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
42typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *obj, int method, const char *name, double lon, double lat); 48typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *obj, int method, const char *name, double lon, double lat);
43 49
@@ -98,6 +104,11 @@ struct _Path
98 Evas_Coord x, y; 104 Evas_Coord x, y;
99}; 105};
100 106
107struct _Region
108{
109 double lon, lat;
110};
111
101struct _Delayed_Data 112struct _Delayed_Data
102{ 113{
103 void (*func)(void *data); 114 void (*func)(void *data);
@@ -120,6 +131,7 @@ struct _Source_Tile
120 Elm_Map_Module_Tile_Url_Func url_cb; 131 Elm_Map_Module_Tile_Url_Func url_cb;
121 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord; 132 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
122 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo; 133 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
134 Elm_Map_Module_Tile_Scale_Func scale_cb;
123}; 135};
124 136
125// Map Route Source 137// Map Route Source
@@ -198,6 +210,37 @@ struct _Overlay_Route
198 Eina_List *nodes; 210 Eina_List *nodes;
199}; 211};
200 212
213struct _Overlay_Line
214{
215 Widget_Data *wd;
216 double flon, flat, tlon, tlat;
217 Evas_Object *obj;
218};
219
220struct _Overlay_Polygon
221{
222 Widget_Data *wd;
223 Eina_List *regions; // list of Regions
224 Evas_Object *obj;
225};
226
227struct _Overlay_Circle
228{
229 Widget_Data *wd;
230 double lon, lat;
231 double radius; // Intial pixel in intial view
232 double ratio; // initial-radius/map-size
233 Evas_Object *obj;
234};
235
236struct _Overlay_Scale
237{
238 Widget_Data *wd;
239 Evas_Coord x, y;
240 Evas_Coord w, h;
241 Evas_Object *obj;
242 };
243
201struct _Elm_Map_Overlay 244struct _Elm_Map_Overlay
202{ 245{
203 Widget_Data *wd; 246 Widget_Data *wd;
@@ -490,14 +533,15 @@ static char *_nominatim_url_cb(const Evas_Object *obj, int method, const char *n
490static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat) 533static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
491static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); 534static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
492*/ 535*/
536static double _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom);
493 537
494const Source_Tile src_tiles[] = 538const Source_Tile src_tiles[] =
495{ 539{
496 {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL}, 540 {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL, _scale_cb},
497 {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL}, 541 {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL, _scale_cb},
498 {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL}, 542 {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL, _scale_cb},
499 {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL}, 543 {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL, _scale_cb},
500 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL}, 544 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL, _scale_cb}
501}; 545};
502 546
503// FIXME: Fix more open sources 547// FIXME: Fix more open sources
@@ -508,6 +552,20 @@ const Source_Route src_routes[] =
508 //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org 552 //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
509}; 553};
510 554
555// Refer : http://wiki.openstreetmap.org/wiki/FAQ
556// meters per pixel when latitude is 0 (equator)
557// meters per pixel = _osm_scale_meter[zoom] * cos (latitude)
558const double _osm_scale_meter[] =
559{78206, 39135.758482, 19567.879241, 9783.939621, 4891.969810,
560 2445.984905, 1222.992453, 611.496226, 305.748113, 152.874057, 76.437028,
561 38.218514, 19.109257, 9.554629, 4.777314, 2.388657, 1.194329, 0.597164,
562 0.29858};
563
564// Scale in meters
565const double _scale_tb[] =
566{10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
567 20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1};
568
511// FIXME: Add more open sources 569// FIXME: Add more open sources
512const Source_Name src_names[] = 570const Source_Name src_names[] =
513{ 571{
@@ -2505,6 +2563,251 @@ _overlay_route_new(Widget_Data *wd, const Elm_Map_Route *route, Color c)
2505} 2563}
2506 2564
2507static void 2565static void
2566_overlay_line_color_update(Overlay_Line *ovl, Color c)
2567{
2568 EINA_SAFETY_ON_NULL_RETURN(ovl);
2569 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2570}
2571
2572static void
2573_overlay_line_hide(Overlay_Line *ovl)
2574{
2575 EINA_SAFETY_ON_NULL_RETURN(ovl);
2576 if (ovl->obj) evas_object_hide(ovl->obj);
2577}
2578
2579static void
2580_overlay_line_show(Overlay_Line *ovl)
2581{
2582 Evas_Coord fx, fy, tx, ty;
2583 Widget_Data *wd = ovl->wd;
2584
2585 _region_to_coord_convert(wd, ovl->flon, ovl->flat, wd->size.w, &fx, &fy);
2586 _region_to_coord_convert(wd, ovl->tlon, ovl->tlat, wd->size.w, &tx, &ty);
2587 _coord_to_canvas(wd, fx, fy, &fx, &fy);
2588 _coord_to_canvas(wd, tx, ty, &tx, &ty);
2589 evas_object_line_xy_set(ovl->obj, fx, fy, tx, ty);
2590 evas_object_show(ovl->obj);
2591}
2592
2593static void
2594_overlay_line_free(Overlay_Line *ovl)
2595{
2596 EINA_SAFETY_ON_NULL_RETURN(ovl);
2597 evas_object_del(ovl->obj);
2598 free(ovl);
2599}
2600
2601static Overlay_Line *
2602_overlay_line_new(Widget_Data *wd, double flon, double flat, double tlon, double tlat, Color c)
2603{
2604 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2605
2606 Overlay_Line *ovl = ELM_NEW(Overlay_Line);
2607 ovl->wd = wd;
2608 ovl->flon = flon;
2609 ovl->flat = flat;
2610 ovl->tlon = tlon;
2611 ovl->tlat = tlat;
2612 ovl->obj = evas_object_line_add(evas_object_evas_get(wd->obj));
2613 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2614 _overlay_line_color_update(ovl, c);
2615 return ovl;
2616}
2617
2618static void
2619_overlay_polygon_color_update(Overlay_Polygon *ovl, Color c)
2620{
2621 EINA_SAFETY_ON_NULL_RETURN(ovl);
2622 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2623}
2624
2625static void
2626_overlay_polygon_hide(Overlay_Polygon *ovl)
2627{
2628 EINA_SAFETY_ON_NULL_RETURN(ovl);
2629 if (ovl->obj) evas_object_hide(ovl->obj);
2630}
2631
2632static void
2633_overlay_polygon_show(Overlay_Polygon *ovl)
2634{
2635 EINA_SAFETY_ON_NULL_RETURN(ovl);
2636 Eina_List *l;
2637 Region *r;
2638 Widget_Data *wd = ovl->wd;
2639
2640 evas_object_polygon_points_clear(ovl->obj);
2641 EINA_LIST_FOREACH(ovl->regions, l, r)
2642 {
2643 Evas_Coord x, y;
2644 _region_to_coord_convert(wd, r->lon, r->lat, wd->size.w, &x, &y);
2645 _coord_to_canvas(wd, x, y, &x, &y);
2646 evas_object_polygon_point_add(ovl->obj, x, y);
2647 }
2648 evas_object_show(ovl->obj);
2649}
2650
2651static void
2652_overlay_polygon_free(Overlay_Polygon *ovl)
2653{
2654 EINA_SAFETY_ON_NULL_RETURN(ovl);
2655 Region *r;
2656 evas_object_del(ovl->obj);
2657 EINA_LIST_FREE(ovl->regions, r) free(r);
2658 free(ovl);
2659}
2660
2661static Overlay_Polygon *
2662_overlay_polygon_new(Widget_Data *wd, Color c)
2663{
2664 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2665
2666 Overlay_Polygon *ovl = ELM_NEW(Overlay_Polygon);
2667 ovl->wd = wd;
2668 ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
2669 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2670 _overlay_polygon_color_update(ovl, c);
2671 return ovl;
2672}
2673
2674static void
2675_overlay_circle_color_update(Overlay_Circle *ovl, Color c)
2676{
2677 EINA_SAFETY_ON_NULL_RETURN(ovl);
2678 Evas_Object *obj = elm_layout_edje_get(ovl->obj);
2679 evas_object_color_set(obj, c.r, c.g, c.b, c.a);
2680}
2681
2682static void
2683_overlay_circle_hide(Overlay_Circle *ovl)
2684{
2685 EINA_SAFETY_ON_NULL_RETURN(ovl);
2686 if (ovl->obj) evas_object_hide(ovl->obj);
2687}
2688
2689static void
2690_overlay_circle_show(Overlay_Circle *ovl)
2691{
2692 EINA_SAFETY_ON_NULL_RETURN(ovl);
2693 double r;
2694 Evas_Coord x, y;
2695 Widget_Data *wd = ovl->wd;
2696
2697 r = (ovl->ratio) * wd->size.w;
2698 _region_to_coord_convert(wd, ovl->lon, ovl->lat, wd->size.w, &x, &y);
2699 _coord_to_canvas(wd, x, y, &x, &y);
2700 _obj_place(ovl->obj, x - r, y - r, r * 2, r * 2);
2701}
2702
2703static void
2704_overlay_circle_free(Overlay_Circle *ovl)
2705{
2706 EINA_SAFETY_ON_NULL_RETURN(ovl);
2707 evas_object_del(ovl->obj);
2708 free(ovl);
2709}
2710
2711static Overlay_Circle *
2712_overlay_circle_new(Widget_Data *wd, double lon, double lat, double radius, Color c)
2713{
2714 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2715
2716 Overlay_Circle *ovl = ELM_NEW(Overlay_Circle);
2717 ovl->wd = wd;
2718 ovl->lon = lon;
2719 ovl->lat = lat;
2720 ovl->radius = radius;
2721 ovl->ratio = radius / wd->size.w;
2722
2723 ovl->obj = elm_layout_add(wd->obj);
2724 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2725 evas_object_stack_above(ovl->obj, wd->sep_maps_markers);
2726 elm_layout_theme_set(ovl->obj, "map/circle", "base",
2727 elm_widget_style_get(wd->obj));
2728 _overlay_circle_color_update(ovl, c);
2729 return ovl;
2730}
2731
2732static void
2733_overlay_scale_color_update(Overlay_Scale *ovl, Color c)
2734{
2735 EINA_SAFETY_ON_NULL_RETURN(ovl);
2736 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2737}
2738
2739static void
2740_overlay_scale_hide(Overlay_Scale *ovl)
2741{
2742 EINA_SAFETY_ON_NULL_RETURN(ovl);
2743 if (ovl->obj) evas_object_hide(ovl->obj);
2744}
2745
2746 static void
2747_overlay_scale_show(Overlay_Scale *ovl)
2748{
2749 EINA_SAFETY_ON_NULL_RETURN(ovl);
2750 Evas_Coord w;
2751 double lon, lat;
2752 double text;
2753 char buf[32];
2754 double meter;
2755 Widget_Data *wd = ovl->wd;
2756
2757 if ((int)sizeof(_scale_tb) <= wd->zoom)
2758 {
2759 ERR("Zoom level is too high");
2760 return;
2761 }
2762
2763 elm_map_region_get(wd->obj, &lon, &lat);
2764 meter = wd->src_tile->scale_cb(wd->obj, lon, lat, wd->zoom);
2765
2766 w = (_scale_tb[wd->zoom] / meter) * (wd->zoom_detail - wd->zoom + 1);
2767
2768 text = _scale_tb[wd->zoom]/1000;
2769 if (text < 1) snprintf(buf, sizeof(buf), "%d m", (int)(text * 1000));
2770 else snprintf(buf, sizeof(buf), "%d km", (int)text);
2771
2772 edje_object_part_text_set(elm_layout_edje_get(ovl->obj), "elm.text", buf);
2773 _obj_place(ovl->obj, ovl->x, ovl->y, w, ovl->h);
2774}
2775
2776 static void
2777_overlay_scale_free(Overlay_Scale *ovl)
2778{
2779 EINA_SAFETY_ON_NULL_RETURN(ovl);
2780 evas_object_del(ovl->obj);
2781 free(ovl);
2782}
2783
2784static Overlay_Scale *
2785_overlay_scale_new(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Color c)
2786{
2787 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2788 const char *s;
2789
2790 Overlay_Scale *ovl = ELM_NEW(Overlay_Scale);
2791 ovl->wd = wd;
2792 ovl->x = x;
2793 ovl->y = y;
2794
2795 ovl->obj = elm_layout_add(wd->obj);
2796 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2797 evas_object_stack_above(ovl->obj, wd->sep_maps_markers);
2798 elm_layout_theme_set(ovl->obj, "map/scale", "base",
2799 elm_widget_style_get(wd->obj));
2800 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_w");
2801 if (s) ovl->w = atoi(s);
2802 else ovl->w = 100;
2803 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_h");
2804 if (s) ovl->h = atoi(s);
2805 else ovl->h = 60;
2806 _overlay_scale_color_update(ovl, c);
2807 return ovl;
2808}
2809
2810static void
2508_overlay_grouping(Eina_List *clas_membs, Elm_Map_Overlay *boss) 2811_overlay_grouping(Eina_List *clas_membs, Elm_Map_Overlay *boss)
2509{ 2812{
2510 EINA_SAFETY_ON_NULL_RETURN(clas_membs); 2813 EINA_SAFETY_ON_NULL_RETURN(clas_membs);
@@ -2594,6 +2897,26 @@ _overlay_show(Elm_Map_Overlay *overlay)
2594 if (hide) _overlay_route_hide(overlay->ovl); 2897 if (hide) _overlay_route_hide(overlay->ovl);
2595 else _overlay_route_show(overlay->ovl); 2898 else _overlay_route_show(overlay->ovl);
2596 } 2899 }
2900 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
2901 {
2902 if (hide) _overlay_line_hide(overlay->ovl);
2903 else _overlay_line_show(overlay->ovl);
2904 }
2905 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
2906 {
2907 if (hide) _overlay_polygon_hide(overlay->ovl);
2908 else _overlay_polygon_show(overlay->ovl);
2909 }
2910 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
2911 {
2912 if (hide) _overlay_circle_hide(overlay->ovl);
2913 else _overlay_circle_show(overlay->ovl);
2914 }
2915 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
2916 {
2917 if (hide) _overlay_scale_hide(overlay->ovl);
2918 else _overlay_scale_show(overlay->ovl);
2919 }
2597} 2920}
2598 2921
2599static void 2922static void
@@ -3291,6 +3614,7 @@ _source_tile_mod_cb(Eina_Module *m, void *data)
3291 Elm_Map_Module_Tile_Url_Func url_cb; 3614 Elm_Map_Module_Tile_Url_Func url_cb;
3292 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord; 3615 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
3293 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo; 3616 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
3617 Elm_Map_Module_Tile_Scale_Func scale_cb;
3294 const char *file; 3618 const char *file;
3295 3619
3296 file = eina_module_file_get(m); 3620 file = eina_module_file_get(m);
@@ -3307,9 +3631,9 @@ _source_tile_mod_cb(Eina_Module *m, void *data)
3307 url_cb = eina_module_symbol_get(m, "map_module_tile_url_get"); 3631 url_cb = eina_module_symbol_get(m, "map_module_tile_url_get");
3308 geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord"); 3632 geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord");
3309 coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo"); 3633 coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo");
3310 3634 scale_cb = eina_module_symbol_get(m, "map_module_tile_scale_get");
3311 if ((!name_cb) || (!zoom_min) || (!zoom_max) || (!url_cb) || 3635 if ((!name_cb) || (!zoom_min) || (!zoom_max) || (!url_cb) ||
3312 (!geo_to_coord) || (!coord_to_geo)) 3636 (!geo_to_coord) || (!coord_to_geo) || (!scale_cb))
3313 { 3637 {
3314 WRN("Could not find map module functions from module \"%s\": %s", 3638 WRN("Could not find map module functions from module \"%s\": %s",
3315 file, eina_error_msg_get(eina_error_get())); 3639 file, eina_error_msg_get(eina_error_get()));
@@ -3323,6 +3647,7 @@ _source_tile_mod_cb(Eina_Module *m, void *data)
3323 s->url_cb = url_cb; 3647 s->url_cb = url_cb;
3324 s->geo_to_coord = geo_to_coord; 3648 s->geo_to_coord = geo_to_coord;
3325 s->coord_to_geo = coord_to_geo; 3649 s->coord_to_geo = coord_to_geo;
3650 s->scale_cb = scale_cb;
3326 wd->src_tiles = eina_list_append(wd->src_tiles, s); 3651 wd->src_tiles = eina_list_append(wd->src_tiles, s);
3327 3652
3328 return EINA_TRUE; 3653 return EINA_TRUE;
@@ -3345,6 +3670,7 @@ _source_tile_load(Widget_Data *wd)
3345 s->url_cb = src_tiles[idx].url_cb; 3670 s->url_cb = src_tiles[idx].url_cb;
3346 s->geo_to_coord = src_tiles[idx].geo_to_coord; 3671 s->geo_to_coord = src_tiles[idx].geo_to_coord;
3347 s->coord_to_geo = src_tiles[idx].coord_to_geo; 3672 s->coord_to_geo = src_tiles[idx].coord_to_geo;
3673 s->scale_cb = src_tiles[idx].scale_cb;
3348 wd->src_tiles = eina_list_append(wd->src_tiles, s); 3674 wd->src_tiles = eina_list_append(wd->src_tiles, s);
3349 } 3675 }
3350 3676
@@ -3880,6 +4206,13 @@ _nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double l
3880 return strdup(buf); 4206 return strdup(buf);
3881} 4207}
3882 4208
4209static double
4210_scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom)
4211{
4212 if (zoom < 0 || zoom >= (int)sizeof(_osm_scale_meter)) return 0;
4213 return _osm_scale_meter[zoom] / cos(lat * ELM_PI / 180.0);
4214}
4215
3883static void 4216static void
3884_on_focus_hook(void *data __UNUSED__, Evas_Object *obj) 4217_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
3885{ 4218{
@@ -4952,6 +5285,14 @@ elm_map_overlay_del(Elm_Map_Overlay *overlay)
4952 _overlay_class_free(overlay->ovl); 5285 _overlay_class_free(overlay->ovl);
4953 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE) 5286 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
4954 _overlay_route_free(overlay->ovl); 5287 _overlay_route_free(overlay->ovl);
5288 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
5289 _overlay_line_free(overlay->ovl);
5290 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
5291 _overlay_polygon_free(overlay->ovl);
5292 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
5293 _overlay_circle_free(overlay->ovl);
5294 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
5295 _overlay_scale_free(overlay->ovl);
4955 else ERR("Invalid overlay type: %d", overlay->type); 5296 else ERR("Invalid overlay type: %d", overlay->type);
4956 5297
4957 overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay); 5298 overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay);
@@ -5308,12 +5649,12 @@ elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
5308 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) 5649 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5309 { 5650 {
5310 const Overlay_Default *ovl = overlay->ovl; 5651 const Overlay_Default *ovl = overlay->ovl;
5311 return elm_object_part_content_get(ovl->layout, "elm.icon"); 5652 return ovl->content;
5312 } 5653 }
5313 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) 5654 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5314 { 5655 {
5315 const Overlay_Class *ovl = overlay->ovl; 5656 const Overlay_Class *ovl = overlay->ovl;
5316 return ovl->icon; 5657 return ovl->content;
5317 } 5658 }
5318 else 5659 else
5319 { 5660 {
@@ -5533,6 +5874,23 @@ elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas)
5533#endif 5874#endif
5534} 5875}
5535 5876
5877EAPI Eina_List *
5878elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp)
5879{
5880#ifdef HAVE_ELEMENTARY_ECORE_CON
5881 EINA_SAFETY_ON_NULL_RETURN_VAL(grp, NULL);
5882 EINA_SAFETY_ON_NULL_RETURN_VAL(grp->wd, NULL);
5883 ELM_CHECK_WIDTYPE(grp->wd->obj, widtype) NULL;
5884 EINA_SAFETY_ON_FALSE_RETURN_VAL(grp->type == ELM_MAP_OVERLAY_TYPE_GROUP, NULL);
5885
5886 Overlay_Group *ovl = grp->ovl;
5887 return ovl->members;
5888#else
5889 (void) clas;
5890 return OVERLAY_CLASS_ZOOM_MAX;
5891#endif
5892}
5893
5536EAPI Elm_Map_Overlay * 5894EAPI Elm_Map_Overlay *
5537elm_map_overlay_bubble_add(Evas_Object *obj) 5895elm_map_overlay_bubble_add(Evas_Object *obj)
5538{ 5896{
@@ -5666,6 +6024,139 @@ elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route)
5666#endif 6024#endif
5667} 6025}
5668 6026
6027EAPI Elm_Map_Overlay *
6028elm_map_overlay_line_add(Evas_Object *obj, double flon, double flat, double tlon, double tlat)
6029{
6030#ifdef HAVE_ELEMENTARY_ECORE_CON
6031 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6032 Widget_Data *wd = elm_widget_data_get(obj);
6033 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
6034
6035 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
6036 overlay->wd = wd;
6037 overlay->type = ELM_MAP_OVERLAY_TYPE_LINE;
6038 overlay->c.r = 0xff;
6039 overlay->c.g = 0x00;
6040 overlay->c.b = 0x00;
6041 overlay->c.a = 0xff;
6042 overlay->ovl = _overlay_line_new(wd, flon, flat, tlon, tlat, overlay->c);
6043 overlay->grp = _overlay_group_new(wd);
6044 wd->overlays = eina_list_append(wd->overlays, overlay);
6045
6046 evas_object_smart_changed(wd->pan_smart);
6047 return overlay;
6048#else
6049 (void) obj;
6050 (void) flon;
6051 (void) flat
6052 (void) tlon;
6053 (void) tlat;
6054 return NULL;
6055#endif
6056}
6057
6058EAPI Elm_Map_Overlay *
6059elm_map_overlay_polygon_add(Evas_Object *obj)
6060{
6061#ifdef HAVE_ELEMENTARY_ECORE_CON
6062 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6063 Widget_Data *wd = elm_widget_data_get(obj);
6064 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
6065
6066 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
6067 overlay->wd = wd;
6068 overlay->type = ELM_MAP_OVERLAY_TYPE_POLYGON;
6069 overlay->c.r = 0xdc;
6070 overlay->c.g = 0x14;
6071 overlay->c.b = 0x3c;
6072 overlay->c.a = 200;
6073 overlay->ovl = _overlay_polygon_new(wd, overlay->c);
6074 overlay->grp = _overlay_group_new(wd);
6075 wd->overlays = eina_list_append(wd->overlays, overlay);
6076 evas_object_smart_changed(wd->pan_smart);
6077 return overlay;
6078#else
6079 (void) obj;
6080 return NULL;
6081#endif
6082}
6083
6084EAPI void
6085elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay, double lon, double lat)
6086{
6087#ifdef HAVE_ELEMENTARY_ECORE_CON
6088 EINA_SAFETY_ON_NULL_RETURN(overlay);
6089 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
6090 EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON);
6091
6092 Overlay_Polygon *ovl = overlay->ovl;
6093 Region *r = ELM_NEW(Region);
6094 r->lon = lon;
6095 r->lat = lat;
6096 ovl->regions = eina_list_append(ovl->regions, r);
6097
6098 evas_object_smart_changed(ovl->wd->pan_smart);
6099#else
6100 (void) overlay;
6101 (void) lon;
6102 (void) lat
6103 #endif
6104}
6105
6106EAPI Elm_Map_Overlay *
6107elm_map_overlay_circle_add(Evas_Object *obj, double lon, double lat, double radius)
6108{
6109#ifdef HAVE_ELEMENTARY_ECORE_CON
6110 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6111 Widget_Data *wd = elm_widget_data_get(obj);
6112 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
6113
6114 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
6115 overlay->wd = wd;
6116 overlay->type = ELM_MAP_OVERLAY_TYPE_CIRCLE;
6117 overlay->c.r = 0xdc;
6118 overlay->c.g = 0x14;
6119 overlay->c.b = 0x3c;
6120 overlay->c.a = 200;
6121 overlay->ovl = _overlay_circle_new(wd, lon, lat, radius, overlay->c);
6122 overlay->grp = _overlay_group_new(wd);
6123 wd->overlays = eina_list_append(wd->overlays, overlay);
6124
6125 evas_object_smart_changed(wd->pan_smart);
6126 return overlay;
6127#else
6128 (void) obj;
6129 return NULL;
6130#endif
6131}
6132
6133EAPI Elm_Map_Overlay *
6134elm_map_overlay_scale_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
6135{
6136#ifdef HAVE_ELEMENTARY_ECORE_CON
6137 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6138 Widget_Data *wd = elm_widget_data_get(obj);
6139 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
6140
6141 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
6142 overlay->wd = wd;
6143 overlay->type = ELM_MAP_OVERLAY_TYPE_SCALE;
6144 overlay->c.r = 0;
6145 overlay->c.g = 0;
6146 overlay->c.b = 0;
6147 overlay->c.a = 255;
6148 overlay->ovl = _overlay_scale_new(wd, x, y, overlay->c);
6149 overlay->grp = _overlay_group_new(wd);
6150 wd->overlays = eina_list_append(wd->overlays, overlay);
6151
6152 evas_object_smart_changed(wd->pan_smart);
6153 return overlay;
6154#else
6155 (void) obj;
6156 return NULL;
6157#endif
6158}
6159
5669#ifdef ELM_EMAP 6160#ifdef ELM_EMAP
5670EAPI Evas_Object * 6161EAPI Evas_Object *
5671elm_map_track_add(Evas_Object *obj, void *emap) 6162elm_map_track_add(Evas_Object *obj, void *emap)
diff --git a/legacy/elementary/src/lib/elm_map.h b/legacy/elementary/src/lib/elm_map.h
index 8b68156c96..b0b89dc41c 100644
--- a/legacy/elementary/src/lib/elm_map.h
+++ b/legacy/elementary/src/lib/elm_map.h
@@ -165,9 +165,14 @@ typedef enum _Elm_Map_Overlay_Type
165 ELM_MAP_OVERLAY_TYPE_NONE = 0, 165 ELM_MAP_OVERLAY_TYPE_NONE = 0,
166 ELM_MAP_OVERLAY_TYPE_DEFAULT, 166 ELM_MAP_OVERLAY_TYPE_DEFAULT,
167 ELM_MAP_OVERLAY_TYPE_CLASS, 167 ELM_MAP_OVERLAY_TYPE_CLASS,
168 ELM_MAP_OVERLAY_TYPE_GROUP,
168 ELM_MAP_OVERLAY_TYPE_BUBBLE, 169 ELM_MAP_OVERLAY_TYPE_BUBBLE,
169 ELM_MAP_OVERLAY_TYPE_ROUTE, 170 ELM_MAP_OVERLAY_TYPE_ROUTE,
170 ELM_MAP_OVERLAY_TYPE_GROUP 171 ELM_MAP_OVERLAY_TYPE_LINE,
172 ELM_MAP_OVERLAY_TYPE_POLYGON,
173 ELM_MAP_OVERLAY_TYPE_CIRCLE,
174 ELM_MAP_OVERLAY_TYPE_SCALE
175
171} Elm_Map_Overlay_Type; 176} Elm_Map_Overlay_Type;
172 177
173typedef struct _Elm_Map_Marker Elm_Map_Marker; /**< A marker to be shown in a specific point of the map. Can be created with elm_map_marker_add() and deleted with elm_map_marker_remove(). */ 178typedef struct _Elm_Map_Marker Elm_Map_Marker; /**< A marker to be shown in a specific point of the map. Can be created with elm_map_marker_add() and deleted with elm_map_marker_remove(). */
@@ -935,6 +940,10 @@ EAPI void elm_map_overlays_show(Eina_List *overlays);
935 * 940 *
936 * If the overlay is clicked, the callback wll be called. 941 * If the overlay is clicked, the callback wll be called.
937 * The clicked overlay is returned by callback. 942 * The clicked overlay is returned by callback.
943 *
944 * You can add callback to the class overlay. If one of the group overlays in this class
945 * is clicked, callback will be called and return a virtual group overlays.
946 *
938 * You can delete this callback function by setting @c NULL. 947 * You can delete this callback function by setting @c NULL.
939 * 948 *
940 * @ingroup Map 949 * @ingroup Map
@@ -956,7 +965,7 @@ EAPI void elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_G
956 * 965 *
957 * You can change the state (hidden, paused, etc.) or set the content 966 * You can change the state (hidden, paused, etc.) or set the content
958 * or icon of the group overlays by chaning the state of the class overlay. 967 * or icon of the group overlays by chaning the state of the class overlay.
959 * Do not control the group overlay itself. 968 * Do not modifty the group overlay itself.
960 * 969 *
961 * Also these changes have a influence on the overlays in the same class 970 * Also these changes have a influence on the overlays in the same class
962 * even if each overlay is alone and is not grouped. 971 * even if each overlay is alone and is not grouped.
@@ -1024,6 +1033,27 @@ EAPI void elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *c
1024EAPI int elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas); 1033EAPI int elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas);
1025 1034
1026/** 1035/**
1036 * Get the overlay members of the group overlay.
1037 *
1038 * @param clas The group overlay has overlay members.
1039 *
1040 * @return The list of group overlay memebers.
1041 *
1042 * The group overlays are virtualy overlays. Those are shown and hidden dynamically.
1043 * You can add callback to the class overlay. If one of the group overlays in this class
1044 * is clicked, callback will be called and return a virtual group overlays.
1045 *
1046 * You can change the state (hidden, paused, etc.) or set the content
1047 * or icon of the group overlays by chaning the state of the class overlay.
1048 * Do not modifty the group overlay itself.
1049 *
1050 * @see elm_map_overlay_class_add()
1051 *
1052 * @ingroup Map
1053 */
1054EAPI Eina_List * elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp);
1055
1056/**
1027 * Add a new bubble overlay to the map object. 1057 * Add a new bubble overlay to the map object.
1028 * This overlay has a bubble type. 1058 * This overlay has a bubble type.
1029 * 1059 *
@@ -1114,6 +1144,98 @@ EAPI void elm_map_overlay_bubble_content_clear(Elm_Map_Overlay
1114EAPI Elm_Map_Overlay * elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route); 1144EAPI Elm_Map_Overlay * elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route);
1115 1145
1116/** 1146/**
1147 * Add a new line overlay to the map object.
1148 * This overlay has a line type.
1149 *
1150 * @param obj The map object to add a new overlay.
1151 * @param flon The start longitude.
1152 * @param flat The start latitude.
1153 * @param tlon The destination longitude.
1154 * @param tlat The destination latitude.
1155 * @return The created overlay or @c NULL upon failure.
1156 *
1157 * Overlay created with this method can be deleted with elm_map_overlay_del().
1158 *
1159 * @see elm_map_overlay_del()
1160 *
1161 * @ingroup Map
1162 */
1163EAPI Elm_Map_Overlay * elm_map_overlay_line_add(Evas_Object *obj, double flon, double flat, double tlon, double tlat);
1164
1165/**
1166 * Add a new polygon overlay to the map object.
1167 * This overlay has a polygon type.
1168 *
1169 * @param obj The map object to add a new overlay.
1170 * @return The created overlay or @c NULL upon failure.
1171 *
1172 * At least 3 regions should be added to show the polygon overlay.
1173 *
1174 * Overlay created with this method can be deleted with elm_map_overlay_del().
1175 *
1176 * @see elm_map_overlay_polygon_region_add()
1177 * @see elm_map_overlay_del()
1178 *
1179 * @ingroup Map
1180 */
1181EAPI Elm_Map_Overlay * elm_map_overlay_polygon_add(Evas_Object *obj);
1182
1183/**
1184 * Add a geographic coordinates to the polygon overlay.
1185 *
1186 * @param overlay The polygon overlay to get a region.
1187 * @param lon The longitude.
1188 * @param lat The latitude.
1189 *
1190 * At least 3 regions should be added to show the polygon overlay.
1191 *
1192 * Overlay created with this method can be deleted with elm_map_overlay_del().
1193 *
1194 * @see elm_map_overlay_polygon_add()
1195 * @see elm_map_overlay_del()
1196 *
1197 * @ingroup Map
1198 */
1199EAPI void elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay, double lon, double lat);
1200
1201/**
1202 * Add a new circle overlay to the map object.
1203 * This overlay has a circle type.
1204 *
1205 * @param obj The map object to add a new overlay.
1206 * @param lon The center longitude.
1207 * @param lat The center latitude.
1208 * @param radius The pixel length of radius.
1209 * @return The created overlay or @c NULL upon failure.
1210 *
1211 * Overlay created with this method can be deleted with elm_map_overlay_del().
1212 *
1213 * @see elm_map_overlay_del()
1214 *
1215 * @ingroup Map
1216 */
1217EAPI Elm_Map_Overlay * elm_map_overlay_circle_add(Evas_Object *obj, double lon, double lat, double radius);
1218
1219/**
1220 * Add a new scale overlay to the map object.
1221 * This overlay has a scale type.
1222 *
1223 * @param obj The map object to add a new overlay.
1224 * @param x horizontal pixel coordinate.
1225 * @param y vertical pixel coordinate
1226 * @return The created overlay or @c NULL upon failure.
1227 *
1228 * The scale overlay shows the ratio of a distance on the map to the corresponding distance.
1229 *
1230 * Overlay created with this method can be deleted with elm_map_overlay_del().
1231 *
1232 * @see elm_map_overlay_del()
1233 *
1234 * @ingroup Map
1235 */
1236EAPI Elm_Map_Overlay * elm_map_overlay_scale_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
1237
1238/**
1117 * Get the information of tile load status. 1239 * Get the information of tile load status.
1118 * 1240 *
1119 * @param obj The map object. 1241 * @param obj The map object.