This code places an Elementary map widget on a window, to exemplify part of the widget\textquotesingle{}s A\+P\+I.

Let\textquotesingle{}s start adding a map to our window\+:  
\begin{DoxyCodeInclude}
   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);

\end{DoxyCodeInclude}


It\textquotesingle{}s enough to display a world map inside our window. But usually you\textquotesingle{}ll need to let user interact with the map. We need to place some buttons, so the user could control the map. It\textquotesingle{}s done on the following code. If you don\textquotesingle{}t know about boxes, or buttons, check their examples, \hyperlink{box_example_01}{Box Example 1} and \hyperlink{button_example_01}{Button Example 1}. 
\begin{DoxyCodeInclude}
   box = elm_box_add(win);
   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);

   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);

   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);

   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);

\end{DoxyCodeInclude}


We are adding callback functions that will be called when the user clicks over these buttons. Let\textquotesingle{}s study such functions, starting from the function that will zoom in the map\+:  
\begin{DoxyCodeInclude}
\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);
\}

\end{DoxyCodeInclude}


First thing done is assure zoom mode is set to manual. It\textquotesingle{}s the default mode, but the other buttons will change this, so before setting a new zoom value, we need to change the zoom mode.

Then, we get the current zoom value, increment that, and set the new value to the map. If it\textquotesingle{}s bigger than max zoom value allowed, it will remain on the maximum allowed, nothing bad will happen. This way we don\textquotesingle{}t need to check first if it won\textquotesingle{}t be bigger than max.

Zoom out function is basically the same thing, but zoom will be decremented instead of incremented\+: 
\begin{DoxyCodeInclude}
\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);
\}

\end{DoxyCodeInclude}


The \char`\"{}\+X\char`\"{} button, when pressed, will call a function that will zoom the map until it fits inside the scroll frame with no pixels outside this area\+: 
\begin{DoxyCodeInclude}
\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);
\}

\end{DoxyCodeInclude}


And the \char`\"{}\#\char`\"{} button, will call a function that will zoom until map fills scroll, ensuring no pixels are left unfilled\+: 
\begin{DoxyCodeInclude}
\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);
\}

\end{DoxyCodeInclude}


But we can also set map to show something different from default world map, changing the zoom level and region shown. Let\textquotesingle{}s pick a wonderful city coordinates, one placed at {\ttfamily  43 20 S, 22 90 W }. Since map uses double variables to represent latitude and longitude, to represent north or east, we should represent it as positive values, and south or west as negative. Also, the value will be represented as degree.\+min. So, for example, our longitude {\ttfamily  43 20 S } will be represented by the value {\ttfamily  -\/43.\+20 }. A zoom set to {\ttfamily 12} should be enough to show a city. 
\begin{DoxyCodeInclude}
   elm_map_region_show(map, -43.2, -22.9);

\end{DoxyCodeInclude}


See \hyperlink{map_example_01_8c-example}{map\+\_\+example\+\_\+01.c} for full source, whose window should look like this picture\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/map_example_01}}
\end{DoxyImageNoCaption}
 