2 //gcc -o location_example_01 location_example_01.c -g `pkg-config --cflags --libs elementary elocation`
4 #include <Elementary.h>
9 static Evas_Object *label, *win;
13 _print_position(Elocation_Position *position)
17 if (!position) return;
18 snprintf(buffer, sizeof(buffer),
19 "<b>GeoClue position reply with data from timestamp</b> %i<br/>"
20 "<b>Latitude:</b> %f<br/>"
21 "<b>Longitude:</b> %f<br/>"
22 "<b>Altitude:</b> %f<br/>"
23 "<b>Accuracy level:</b> %i<br/>"
24 "<b>Accuracy horizontal:</b> %f<br/>"
25 "<b>Accuracy vertical:</b> %f",
26 position->timestamp, position->latitude, position->longitude,
27 position->altitude, position->accur->level,
28 position->accur->horizontal, position->accur->vertical);
29 elm_object_text_set(label, buffer);
33 _position_changed(void *data, int ev_type, void *event)
35 Elocation_Position *position;
38 _print_position(position);
39 return ECORE_CALLBACK_DONE;
44 elm_main(int argc, char *argv[])
47 Elocation_Address *address;
48 Elocation_Position *position;
51 /* The program will proceed only if Ewebkit library is available. */
52 if (elm_need_elocation() == EINA_FALSE)
55 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
57 win = elm_win_util_standard_add("elocation", "Elocation example");
58 elm_win_autodel_set(win, EINA_TRUE);
60 label = elm_label_add(win);
61 elm_label_line_wrap_set(label, ELM_WRAP_CHAR);
62 elm_object_text_set(label, "Getting location ...");
63 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
64 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
65 elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_ALWAYS);
66 evas_object_resize(label, 600, 480);
67 evas_object_show(label);
70 address = elocation_address_new();
71 position = elocation_position_new();
73 ecore_event_handler_add(ELOCATION_EVENT_POSITION, _position_changed, NULL);
75 elocation_position_get(position);
76 _print_position(position);
79 evas_object_resize(win, 600, 480);
80 evas_object_show(win);
85 elocation_position_free(position);
86 elocation_address_free(address);