\section{map\+\_\+example\+\_\+03.\+c}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Data
\{
   Evas\_Object *map, *entry;
   Elm_Map_Route *route;
   \textcolor{keywordtype}{double} start\_lon, start\_lat, dest\_lon, dest\_lat;
   Elm_Map_Name *name;
   Elm_Map_Overlay *route\_ovl;
\} Example\_Data;

\textcolor{keyword}{static} Example\_Data example\_data;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_route\_loaded(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   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);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_name\_loaded(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   Example\_Data *exam\_data = data;
   Evas\_Object *map = obj;

   \textcolor{keywordflow}{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);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bt\_route(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   Example\_Data *exam\_data = data;
   Evas\_Object *map;
   \textcolor{keywordtype}{char} *address;

   map = exam\_data->map;
   address = (\textcolor{keywordtype}{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, \textcolor{stringliteral}{"name,loaded"}, \_name\_loaded, data);
   evas\_object\_smart\_callback\_add(map, \textcolor{stringliteral}{"route,loaded"}, \_route\_loaded, data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bt\_zoom\_in(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   \textcolor{keywordtype}{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);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bt\_zoom\_out(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *ev)
\{
   \textcolor{keywordtype}{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);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bt\_zoom\_fit(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FIT);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bt\_zoom\_fill(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FILL);
\}

\textcolor{comment}{/* FIXME: it shouldn't be required. For unknown reason map won't call}
\textcolor{comment}{ * pan\_calculate until shot delay time, but then it will take a screenshot}
\textcolor{comment}{ * when the map isn't loaded yet (actually it won't be downloaded, because}
\textcolor{comment}{ * after the SS it will kill the example). */}
\textcolor{keyword}{static} Eina\_Bool
\_nasty\_hack(\textcolor{keywordtype}{void} *data)
\{
   Evas\_Object *o = data;
   Evas *e = evas\_object\_evas\_get(o);
   evas\_smart\_objects\_calculate(e);
   \textcolor{keywordflow}{return} ECORE\_CALLBACK\_CANCEL;
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   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(\textcolor{stringliteral}{"map"}, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"+"});
   elm_box_pack_end(box, bt);
   evas\_object\_show(bt);
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"-"});
   elm_box_pack_end(box, bt);
   evas\_object\_show(bt);
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"X"});
   elm_box_pack_end(box, bt);
   evas\_object\_show(bt);
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"#"});
   elm_box_pack_end(box, bt);
   evas\_object\_show(bt);
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"Route"});
   elm_box_pack_end(box, bt);
   evas\_object\_show(bt);
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"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();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 