2 * Simple Elementary's <b>map widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g `pkg-config --cflags --libs elementary` map_example_01.c -o map_example_01
12 #include <Elementary.h>
14 # include "elementary_config.h"
20 _bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
22 Evas_Object *map = data;
25 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_MANUAL);
26 zoom = elm_map_zoom_get(map);
27 elm_map_zoom_set(map, zoom + 1);
31 _bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
33 Evas_Object *map = data;
36 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_MANUAL);
37 zoom = elm_map_zoom_get(map);
38 elm_map_zoom_set(map, zoom - 1);
42 _bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
44 Evas_Object *map = data;
45 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_AUTO_FIT);
49 _bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
51 Evas_Object *map = data;
52 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_AUTO_FILL);
56 _on_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
61 /* FIXME: it shouldn't be required. For unknown reason map won't call
62 * pan_calculate until shot delay time, but then it will take a screenshot
63 * when the map isn't loaded yet (actually it won't be downloaded, because
64 * after the SS it will kill the example). */
66 _nasty_hack(void *data)
68 Evas_Object *o = data;
69 Evas *e = evas_object_evas_get(o);
70 evas_smart_objects_calculate(e);
71 return ECORE_CALLBACK_CANCEL;
75 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
77 Evas_Object *win, *bg, *map, *box, *bt;
79 win = elm_win_add(NULL, "map", ELM_WIN_BASIC);
80 elm_win_title_set(win, "Map Creation Example");
81 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
84 elm_win_resize_object_add(win, bg);
85 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
88 map = elm_map_add(win);
89 elm_win_resize_object_add(win, map);
90 evas_object_size_hint_weight_set(map, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
91 evas_object_show(map);
93 box = elm_box_add(win);
94 evas_object_show(box);
96 bt = elm_button_add(win);
97 elm_object_text_set(bt, "+");
98 elm_box_pack_end(box, bt);
100 evas_object_smart_callback_add(bt, "clicked", _bt_zoom_in, map);
102 bt = elm_button_add(win);
103 elm_object_text_set(bt, "-");
104 elm_box_pack_end(box, bt);
105 evas_object_show(bt);
106 evas_object_smart_callback_add(bt, "clicked", _bt_zoom_out, map);
108 bt = elm_button_add(win);
109 elm_object_text_set(bt, "X");
110 elm_box_pack_end(box, bt);
111 evas_object_show(bt);
112 evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fit, map);
114 bt = elm_button_add(win);
115 elm_object_text_set(bt, "#");
116 elm_box_pack_end(box, bt);
117 evas_object_show(bt);
118 evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fill, map);
120 elm_map_geo_region_show(map, -43.2, -22.9);
121 elm_map_zoom_set(map, 12);
123 evas_object_resize(win, 512, 512);
124 evas_object_show(win);
126 ecore_timer_add(0.5, _nasty_hack, win);