map_example_03.c
#include <Elementary.h>
typedef struct _Example_Data
{
Evas_Object *map, *entry;
Elm_Map_Route *route;
double start_lon, start_lat, dest_lon, dest_lat;
Elm_Map_Name *name;
Elm_Map_Overlay *route_ovl;
} Example_Data;
static Example_Data example_data;
static void
_route_loaded(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
{
Example_Data *exam_data = data;
exam_data->route_ovl = elm_map_overlay_route_add(obj, exam_data->route);
elm_map_overlay_color_set(exam_data->route_ovl, 0, 255, 0, 255);
}
static void
_name_loaded(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
{
Example_Data *exam_data = data;
Evas_Object *map = obj;
if (exam_data->route)
elm_map_route_del(exam_data->route);
elm_map_name_region_get(exam_data->name, &(exam_data->dest_lon),
&(exam_data->dest_lat));
exam_data->route = elm_map_route_add(map, ELM_MAP_ROUTE_TYPE_FOOT,
ELM_MAP_ROUTE_METHOD_SHORTEST,
exam_data->start_lon, exam_data->start_lat,
exam_data->dest_lon, exam_data->dest_lat,
NULL, NULL);
}
static void
_bt_route(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
Example_Data *exam_data = data;
Evas_Object *map;
char *address;
map = exam_data->map;
address = (char *)elm_object_text_get(exam_data->entry);
exam_data->name = elm_map_name_add(map, address, 0, 0, NULL, NULL);
evas_object_smart_callback_add(map, "name,loaded", _name_loaded, data);
evas_object_smart_callback_add(map, "route,loaded", _route_loaded, data);
}
static void
_bt_zoom_in(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
int zoom;
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
zoom = elm_map_zoom_get(data);
elm_map_zoom_set(data, zoom + 1);
}
static void
_bt_zoom_out(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
int zoom;
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
zoom = elm_map_zoom_get(data);
elm_map_zoom_set(data, zoom - 1);
}
static void
_bt_zoom_fit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FIT);
}
static void
_bt_zoom_fill(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FILL);
}
/* FIXME: it shouldn't be required. For unknown reason map won't call
* pan_calculate until shot delay time, but then it will take a screenshot
* when the map isn't loaded yet (actually it won't be downloaded, because
* after the SS it will kill the example). */
static Eina_Bool
_nasty_hack(void *data)
{
Evas_Object *o = data;
Evas *e = evas_object_evas_get(o);
evas_smart_objects_calculate(e);
return ECORE_CALLBACK_CANCEL;
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *map, *box, *bt, *entry;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("map", "Map Route Example");
elm_win_autodel_set(win, EINA_TRUE);
map = elm_map_add(win);
evas_object_size_hint_weight_set(map, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, map);
evas_object_show(map);
box = elm_box_add(win);
elm_box_horizontal_set(box, EINA_TRUE);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
bt = elm_button_add(win);
elm_object_text_set(bt, "+");
elm_box_pack_end(box, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_in, map);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "-");
elm_box_pack_end(box, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_out, map);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "X");
elm_box_pack_end(box, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fit, map);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "#");
elm_box_pack_end(box, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fill, map);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0);
entry = elm_entry_add(win);
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_entry_single_line_set(entry, EINA_TRUE);
elm_object_text_set(entry, "Jockey Club Brasileiro");
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0);
elm_box_pack_end(box, entry);
evas_object_show(entry);
bt = elm_button_add(win);
elm_object_text_set(bt, "Route");
elm_box_pack_end(box, bt);
evas_object_show(bt);
evas_object_smart_callback_add(bt, "clicked", _bt_route, &example_data);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0);
example_data.map = map;
example_data.entry = entry;
example_data.route = NULL;
example_data.start_lon = -43.175;
example_data.start_lat = -22.97;
elm_map_zoom_set(map, 12);
elm_map_region_show(map, example_data.start_lon, example_data.start_lat);
evas_object_resize(win, 512, 512);
evas_object_show(win);
ecore_timer_add(0.5, _nasty_hack, win);
elm_run();
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
EVAS_HINT_FILL
#define EVAS_HINT_FILL
Use with evas_object_size_hint_align_set(), evas_object_size_hint_align_get(), evas_object_size_hint_...
Definition Evas_Common.h:298
ECORE_CALLBACK_CANCEL
#define ECORE_CALLBACK_CANCEL
Return value to remove a callback.
Definition Ecore_Common.h:152
ecore_timer_add
Ecore_Timer * ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
Creates a timer to call the given function in the given period of time.
Definition ecore_timer.c:189
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
Eina_Bool
unsigned char Eina_Bool
Type to mimic a boolean.
Definition eina_types.h:527
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
elm_box_horizontal_set
void elm_box_horizontal_set(Elm_Box *obj, Eina_Bool horizontal)
Set the horizontal orientation.
Definition elm_box_eo.legacy.c:27
elm_box_add
Evas_Object * elm_box_add(Evas_Object *parent)
Add a new box to the parent.
Definition elm_box.c:363
elm_box_pack_end
void elm_box_pack_end(Elm_Box *obj, Efl_Canvas_Object *subobj)
Add an object at the end of the pack list.
Definition elm_box_eo.legacy.c:57
elm_button_add
Evas_Object * elm_button_add(Evas_Object *parent)
Add a new button to the parent's canvas.
Definition efl_ui_button.c:459
elm_entry_scrollable_set
void elm_entry_scrollable_set(Elm_Entry *obj, Eina_Bool scroll)
Enable or disable scrolling in entry.
Definition elm_entry_eo.legacy.c:3
elm_entry_single_line_set
void elm_entry_single_line_set(Elm_Entry *obj, Eina_Bool single_line)
Sets the entry to single line mode.
Definition elm_entry_eo.legacy.c:123
elm_entry_add
Evas_Object * elm_entry_add(Evas_Object *parent)
This adds an entry to parent object.
Definition elm_entry.c:4183
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
Elm_Map_Route
struct _Elm_Map_Route Elm_Map_Route
A route to be shown in the map.
Definition elm_map_common.h:39
elm_map_overlay_color_set
void elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g, int b, int a)
Widget is broken due to on-line service API breaks.
Definition elm_map.c:523
elm_map_route_add
Elm_Map_Route * elm_map_route_add(Elm_Map *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat, Elm_Map_Route_Cb route_cb, void *data)
Widget is broken due to on-line service API breaks.
Definition elm_map_eo.legacy.c:81
elm_map_name_add
Elm_Map_Name * elm_map_name_add(const Elm_Map *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
Widget is broken due to on-line service API breaks.
Definition elm_map_eo.legacy.c:141
elm_map_zoom_set
void elm_map_zoom_set(Eo *obj, int zoom)
Widget is broken due to on-line service API breaks Widget is broken due to on-line service API breaks...
Definition elm_map.c:279
Elm_Map_Overlay
struct _Elm_Map_Overlay Elm_Map_Overlay
A overlay to be shown in a specific point of the map.
Definition elm_map_common.h:41
elm_map_overlay_route_add
Elm_Map_Overlay * elm_map_overlay_route_add(Elm_Map *obj, const Elm_Map_Route *route)
Widget is broken due to on-line service API breaks.
Definition elm_map_eo.legacy.c:171
Elm_Map_Name
struct _Elm_Map_Name Elm_Map_Name
A handle for specific coordinates.
Definition elm_map_common.h:40
elm_map_zoom_get
int elm_map_zoom_get(const Eo *obj)
Widget is broken due to on-line service API breaks Widget is broken due to on-line service API breaks...
Definition elm_map.c:283
elm_map_add
Evas_Object * elm_map_add(Evas_Object *parent)
Widget is broken due to on-line service API breaks.
Definition elm_map.c:250
elm_map_zoom_mode_set
void elm_map_zoom_mode_set(Eo *obj, Elm_Map_Zoom_Mode mode)
Widget is broken due to on-line service API breaks Widget is broken due to on-line service API breaks...
Definition elm_map.c:295
elm_map_region_show
void elm_map_region_show(Elm_Map *obj, double lon, double lat)
Widget is broken due to on-line service API breaks.
Definition elm_map_eo.legacy.c:135
elm_map_name_region_get
void elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
Widget is broken due to on-line service API breaks.
Definition elm_map.c:423
elm_map_route_del
void elm_map_route_del(Elm_Map_Route *route)
Widget is broken due to on-line service API breaks.
Definition elm_map.c:391
ELM_MAP_ZOOM_MODE_AUTO_FIT
@ ELM_MAP_ZOOM_MODE_AUTO_FIT
Zoom until map fits inside the scroll frame with no pixels outside this area.
Definition elm_map_legacy.h:10
ELM_MAP_ZOOM_MODE_MANUAL
@ ELM_MAP_ZOOM_MODE_MANUAL
Zoom controlled manually by elm_map_zoom_set().
Definition elm_map_legacy.h:8
ELM_MAP_ZOOM_MODE_AUTO_FILL
@ ELM_MAP_ZOOM_MODE_AUTO_FILL
Zoom until map fills scroll, ensuring no pixels are left unfilled.
Definition elm_map_legacy.h:12
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9587
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition efl_ui_win.c:9002
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6199
Evas
Eo Evas
An opaque handle to an Evas canvas.
Definition Evas_Common.h:163
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_evas_get
EVAS_API Evas * evas_object_evas_get(const Eo *eo_obj)
Get the Evas to which this object belongs to.
Definition evas_object_main.c:2662
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
evas_object_size_hint_align_set
EVAS_API void evas_object_size_hint_align_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's alignment.
Definition evas_object_main.c:2650
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_smart_objects_calculate
EVAS_API void evas_smart_objects_calculate(Eo *eo_e)
Call user-provided calculate smart functions and unset the flag signalling that the object needs to g...
Definition evas_main.c:1996
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040