summaryrefslogtreecommitdiff
path: root/efl/elementary/map.pyx
blob: f5c82a9b4ab7362cec4614869b4b6cfd5cf23d57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
# Copyright (C) 2007-2014 various contributors (see AUTHORS)
#
# This file is part of Python-EFL.
#
# Python-EFL is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# Python-EFL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this Python-EFL.  If not, see <http://www.gnu.org/licenses/>.
#

"""

.. image:: /images/map-preview.png
    :width: 100%

Widget description
------------------

The *Map* is a widget specifically for displaying a geographic map.
It uses `OpenStreetMap <http://www.openstreetmap.org/>`_ as map tile provider,
`YOURS <http://www.yournavigation.org/>`_ for routing calculation and
`Nominatim <http://nominatim.openstreetmap.org/>`_ to convert geographic
coordinates to/from address names. But custom providers can be added.

It supports some basic but yet nice features:

- zooming and scrolling
- markers with content to be displayed when user clicks over them
- automatic grouping of markers based on zoom level
- routes calculation
- names/coordinates conversion (and viceversa)


Signals you can listen to
=========================

- ``clicked`` - Called when a user has clicked the map without dragging around.
- ``clicked,double`` - Called when a user has double-clicked the map.
- ``press`` - This is called when a user has pressed down on the map.
- ``longpressed`` - This is called when a user has pressed down on the map
  for a long time without dragging around.
- ``scroll`` - the content has been scrolled (moved).
- ``scroll,drag,start`` - dragging the contents around has started.
- ``scroll,drag,stop`` - dragging the contents around has stopped.
- ``scroll,anim,start`` - scrolling animation has started.
- ``scroll,anim,stop`` - scrolling animation has stopped.
- ``zoom,start`` - Zoom animation started.
- ``zoom,stop`` - Zoom animation stopped.
- ``zoom,change`` - Zoom changed when using an auto zoom mode.
- ``tile,load`` - A map tile image load begins.
- ``tile,loaded`` -  A map tile image load ends.
- ``tile,loaded,fail`` -  A map tile image load fails.
- ``route,load`` - Route request begins.
- ``route,loaded`` - Route request ends.
- ``route,loaded,fail`` - Route request fails.
- ``name,load`` - Name request begins.
- ``name,loaded`` - Name request ends.
- ``name,loaded,fail`` - Name request fails.
- ``overlay,clicked`` - A overlay is clicked.
- ``loaded`` - when a map is finally loaded.
- ``language,changed`` - the program's language changed
- ``focused`` - When the map has received focus. (since 1.8)
- ``unfocused`` - When the map has lost focus. (since 1.8)

Scrollable Interface
====================

This widget supports the scrollable interface.

If you wish to control the scolling behaviour using these functions,
inherit both the widget class and the
:py:class:`Scrollable<efl.elementary.scroller.Scrollable>` class
using multiple inheritance, for example::

    class ScrollableGenlist(Genlist, Scrollable):
        def __init__(self, canvas, *args, **kwargs):
            Genlist.__init__(self, canvas)

Enumerations
------------

.. _Elm_Map_Overlay_Type:

Map overlay types
=================

.. data:: ELM_MAP_OVERLAY_TYPE_NONE

    None

.. data:: ELM_MAP_OVERLAY_TYPE_DEFAULT

    The default overlay type.

.. data:: ELM_MAP_OVERLAY_TYPE_CLASS

    The Class overlay is used to group marker together.

.. data:: ELM_MAP_OVERLAY_TYPE_GROUP

    A group of overlays.

.. data:: ELM_MAP_OVERLAY_TYPE_BUBBLE

    This class can *follow* another overlay.

.. data:: ELM_MAP_OVERLAY_TYPE_ROUTE

    This is used to draw a route result on the map.

.. data:: ELM_MAP_OVERLAY_TYPE_LINE

    Simply draw a line on the map.

.. data:: ELM_MAP_OVERLAY_TYPE_POLYGON

    Simply draw a polygon on the map.

.. data:: ELM_MAP_OVERLAY_TYPE_CIRCLE

    Simply draw a circle on the map.

.. data:: ELM_MAP_OVERLAY_TYPE_SCALE

    This will draw a dinamic scale on the map.


.. _Elm_Map_Route_Method:

Map route methods
=================

.. data:: ELM_MAP_ROUTE_METHOD_FASTEST

    Route should prioritize time

.. data:: ELM_MAP_ROUTE_METHOD_SHORTEST

    Route should prioritize distance


.. _Elm_Map_Route_Type:

Map route types
===============

.. data:: ELM_MAP_ROUTE_TYPE_MOTOCAR

    Route should consider an automobile will be used.

.. data:: ELM_MAP_ROUTE_TYPE_BICYCLE

    Route should consider a bicycle will be used by the user.

.. data:: ELM_MAP_ROUTE_TYPE_FOOT

    Route should consider user will be walking.


.. _Elm_Map_Source_Type:

Map source types
================

.. data:: ELM_MAP_SOURCE_TYPE_TILE

    Map tile provider

.. data:: ELM_MAP_SOURCE_TYPE_ROUTE

    Route service provider

.. data:: ELM_MAP_SOURCE_TYPE_NAME

    Name service provider


.. _Elm_Map_Zoom_Mode:

Map zoom modes
==============

.. data:: ELM_MAP_ZOOM_MODE_MANUAL

    Zoom controlled manually by :py:attr:`~Map.zoom`

    It's set by default.

.. data:: ELM_MAP_ZOOM_MODE_AUTO_FIT

    Zoom until map fits inside the scroll frame with no pixels outside this
    area.

.. data:: ELM_MAP_ZOOM_MODE_AUTO_FILL

    Zoom until map fills scroll, ensuring no pixels are left unfilled.

"""

from cpython cimport PyUnicode_AsUTF8String, Py_INCREF, Py_DECREF

from efl.eo cimport _object_mapping_register, object_from_instance
from efl.utils.conversions cimport _ctouni
from efl.evas cimport Object as evasObject
from object cimport Object

from efl.evas cimport eina_list_free, eina_list_append
import traceback

from efl.utils.deprecated cimport DEPRECATED
from scroller cimport elm_scroller_policy_get, elm_scroller_policy_set, \
    elm_scroller_bounce_get, elm_scroller_bounce_set, Elm_Scroller_Policy

cimport enums

ELM_MAP_OVERLAY_TYPE_NONE = enums.ELM_MAP_OVERLAY_TYPE_NONE
ELM_MAP_OVERLAY_TYPE_DEFAULT = enums.ELM_MAP_OVERLAY_TYPE_DEFAULT
ELM_MAP_OVERLAY_TYPE_CLASS = enums.ELM_MAP_OVERLAY_TYPE_CLASS
ELM_MAP_OVERLAY_TYPE_GROUP = enums.ELM_MAP_OVERLAY_TYPE_GROUP
ELM_MAP_OVERLAY_TYPE_BUBBLE = enums.ELM_MAP_OVERLAY_TYPE_BUBBLE
ELM_MAP_OVERLAY_TYPE_ROUTE = enums.ELM_MAP_OVERLAY_TYPE_ROUTE
ELM_MAP_OVERLAY_TYPE_LINE = enums.ELM_MAP_OVERLAY_TYPE_LINE
ELM_MAP_OVERLAY_TYPE_POLYGON = enums.ELM_MAP_OVERLAY_TYPE_POLYGON
ELM_MAP_OVERLAY_TYPE_CIRCLE = enums.ELM_MAP_OVERLAY_TYPE_CIRCLE
ELM_MAP_OVERLAY_TYPE_SCALE = enums.ELM_MAP_OVERLAY_TYPE_SCALE

ELM_MAP_ROUTE_METHOD_FASTEST = enums.ELM_MAP_ROUTE_METHOD_FASTEST
ELM_MAP_ROUTE_METHOD_SHORTEST = enums.ELM_MAP_ROUTE_METHOD_SHORTEST
ELM_MAP_ROUTE_METHOD_LAST = enums.ELM_MAP_ROUTE_METHOD_LAST

ELM_MAP_ROUTE_TYPE_MOTOCAR = enums.ELM_MAP_ROUTE_TYPE_MOTOCAR
ELM_MAP_ROUTE_TYPE_BICYCLE = enums.ELM_MAP_ROUTE_TYPE_BICYCLE
ELM_MAP_ROUTE_TYPE_FOOT = enums.ELM_MAP_ROUTE_TYPE_FOOT
ELM_MAP_ROUTE_TYPE_LAST = enums.ELM_MAP_ROUTE_TYPE_LAST

ELM_MAP_SOURCE_TYPE_TILE = enums.ELM_MAP_SOURCE_TYPE_TILE
ELM_MAP_SOURCE_TYPE_ROUTE = enums.ELM_MAP_SOURCE_TYPE_ROUTE
ELM_MAP_SOURCE_TYPE_NAME = enums.ELM_MAP_SOURCE_TYPE_NAME
ELM_MAP_SOURCE_TYPE_LAST = enums.ELM_MAP_SOURCE_TYPE_LAST

ELM_MAP_ZOOM_MODE_MANUAL = enums.ELM_MAP_ZOOM_MODE_MANUAL
ELM_MAP_ZOOM_MODE_AUTO_FIT = enums.ELM_MAP_ZOOM_MODE_AUTO_FIT
ELM_MAP_ZOOM_MODE_AUTO_FILL = enums.ELM_MAP_ZOOM_MODE_AUTO_FILL
ELM_MAP_ZOOM_MODE_LAST = enums.ELM_MAP_ZOOM_MODE_LAST


cdef object _elm_map_overlay_to_python(Elm_Map_Overlay *ov):
    cdef void *data

    if ov == NULL:
        return None
    data = elm_map_overlay_data_get(ov)
    if data == NULL:
        return None
    return <object>data

cdef void _map_overlay_get_callback(void *data, Evas_Object *map, Elm_Map_Overlay *overlay) with gil:
    cdef Object obj

    obj = object_from_instance(map)
    try:
        (func, args, kwargs) = <object>data
        func(obj, _elm_map_overlay_to_python(overlay), *args, **kwargs)
    except Exception:
        traceback.print_exc()

cdef void _map_overlay_del_cb(void *data, Evas_Object *map, Elm_Map_Overlay *overlay) with gil:
    ov = <object>data
    ov.__del_cb()

cdef void _map_route_callback(void *data, Evas_Object *map, Elm_Map_Route *route) with gil:
    cdef Object obj

    obj = object_from_instance(map)
    (proute, func, args, kwargs) = <object>data
    try:
        func(obj, proute, *args, **kwargs)
    except Exception:
        traceback.print_exc()

    Py_DECREF(<object>data)

cdef void _map_name_callback(void *data, Evas_Object *map, Elm_Map_Name *name) with gil:
    cdef Object obj

    obj = object_from_instance(map)
    (pname, func, args, kwargs) = <object>data
    try:
        func(obj, pname, *args, **kwargs)
    except Exception:
        traceback.print_exc()

    Py_DECREF(<object>data)


cdef class MapRoute(object):
    """

    This class represents a calculated route.

    A route will be traced by point on coordinates to point on coordinates
    , using the route service set with :py:func:`Map.source_set()`.

    .. seealso:: :py:func:`Map.route_add`

    """
    cdef Elm_Map_Route *route

    def __cinit__(self):
        self.route = NULL

    def __init__(self, evasObject map,
                       Elm_Map_Route_Type type, Elm_Map_Route_Method method,
                       double flon, double flat, double tlon, double tlat,
                       func, *args, **kwargs):

        if not callable(func):
            raise TypeError("func must be callable")

        data = (self, func, args, kwargs)
        self.route = elm_map_route_add(map.obj, type, method,
                                       flon, flat, tlon, tlat,
                                       _map_route_callback, <void *>data)
        Py_INCREF(data)
        Py_INCREF(self)

    def delete(self):
        """ Remove a route from the map. """
        elm_map_route_del(self.route)
        self.route = NULL
        Py_DECREF(self)

    property distance:
        """ The route distance in kilometers.

        :type: float

        """
        def __get__(self):
            return elm_map_route_distance_get(self.route)

    def distance_get(self):
        return elm_map_route_distance_get(self.route)

    property node:
        """ Get the informational text of the route nodes.

        :type: string

        """
        def __get__(self):
            return _ctouni(elm_map_route_node_get(self.route))

    def node_get(self):
        return _ctouni(elm_map_route_node_get(self.route))

    property waypoint:
        """ Get the informational text of the route waypoints.

        :type: string

        """
        def __get__(self):
            return _ctouni(elm_map_route_waypoint_get(self.route))

    def waypoint_get(self):
        return _ctouni(elm_map_route_waypoint_get(self.route))


cdef class MapName(object):
    """

    This class represent the result of a name/coordinates query and can
    be used to extract the needed information from the results.

    """
    cdef Elm_Map_Name *name

    def __cinit__(self):
        self.name = NULL

    def __init__(self, evasObject map, address, double lon, double lat,
                       func, *args, **kwargs):
        if not callable(func):
            raise TypeError("func must be callable")

        data = (self, func, args, kwargs)
        if isinstance(address, unicode): address = PyUnicode_AsUTF8String(address)
        self.name = elm_map_name_add(map.obj,
            <const char *>address if address is not None else NULL,
            lon, lat, _map_name_callback, <void *>data)
        Py_INCREF(data)
        # XXX: why incref self in __init__?
        Py_INCREF(self)

    def delete(self):
        """ Remove a name from the map. """
        elm_map_name_del(self.name)
        self.name = NULL
        Py_DECREF(self)

    property address:
        """ The address of the name object.

        :type: string

        """
        def __get__(self):
            return _ctouni(elm_map_name_address_get(self.name))

    def address_get(self):
        return _ctouni(elm_map_name_address_get(self.name))

    property region:
        """ Get the coordinates of the name.

        :type: tuple of float (lon, lat)

        """
        def __get__(self):
            cdef double lon, lat

            elm_map_name_region_get(self.name, &lon, &lat)
            return (lon, lat)

    def region_get(self):
        cdef double lon, lat
        elm_map_name_region_get(self.name, &lon, &lat)
        return (lon, lat)


cdef class MapOverlay(object):
    """

    Base class for all the MapOverlay objects

    .. seealso:: :py:func:`Map.overlay_add`

    """
    cdef Elm_Map_Overlay *overlay
    cdef void* cb_get_data

    def __cinit__(self):
        self.overlay = NULL
        self.cb_get_data = NULL

    def __init__(self, evasObject Map, double lon, double lat):
        self.overlay = elm_map_overlay_add(Map.obj, lon, lat)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)

    def __del_cb(self):
        self.overlay = NULL
        Py_DECREF(self)

    def delete(self):
        """ Delete the overlay and remove it from the map """
        if self.overlay == NULL:
            raise ValueError("Object already deleted")
        elm_map_overlay_del(self.overlay)

    property type:
        """Get the type of the overlay

        :type: :ref:`Elm_Map_Overlay_Type`

        """
        def __get__(self):
            return elm_map_overlay_type_get(self.overlay)

    def type_get(self):
        return elm_map_overlay_type_get(self.overlay)

    property hide:
        """ If the overlay is hidden or not.

        :type: bool

        """
        def __get__(self):
            return bool(elm_map_overlay_hide_get(self.overlay))

        def __set__(self, hide):
            elm_map_overlay_hide_set(self.overlay, bool(hide))

    def hide_set(self, hide):
        elm_map_overlay_hide_set(self.overlay, bool(hide))
    def hide_get(self):
        return bool(elm_map_overlay_hide_get(self.overlay))

    property displayed_zoom_min:
        """ The minimum zoom from where the overlay is displayed.

        The overlay only will be displayed when the map is displayed at
        this value or bigger.

        :type: int

        """
        def __get__(self):
            return elm_map_overlay_displayed_zoom_min_get(self.overlay)

        def __set__(self, zoom):
            elm_map_overlay_displayed_zoom_min_set(self.overlay, zoom)

    def displayed_zoom_min_set(self, zoom):
        elm_map_overlay_displayed_zoom_min_set(self.overlay, zoom)
    def displayed_zoom_min_get(self):
        return elm_map_overlay_displayed_zoom_min_get(self.overlay)

    property paused:
        """ Pause or unpause the overlay.

        This sets the paused state to on (*True*) or off (*False*)
        for the overlay.

        The default is off.

        This will stop moving the overlay coordinates instantly.
        even if map being scrolled or zoomed.

        :type: bool

        """
        def __get__(self):
            return elm_map_overlay_paused_get(self.overlay)

        def __set__(self, paused):
            elm_map_overlay_paused_set(self.overlay, paused)

    def paused_set(self, paused):
        elm_map_overlay_paused_set(self.overlay, paused)
    def paused_get(self):
        return elm_map_overlay_paused_get(self.overlay)

    property visible:
        """ Whether the overlay is visible or not.

        The visible of the overlay can not be set. This value can only change
        dynamically while zooming and panning.

        :type: bool

        """
        def __get__(self):
            return bool(elm_map_overlay_visible_get(self.overlay))

    def visible_get(self):
        return bool(elm_map_overlay_visible_get(self.overlay))

    property content:
        """ The content object of the overlay.

        The content should be resized or set size hints before set to the overlay.

        This content is what will be inside the overlay that will be displayed.
        If a content is set, icon and default style layout are no more used before
        the content is deleted.

        :type: :py:class:`efl.evas.Object`

        .. note:: Only `default` and `class` type overlay support this function.
        .. warning:: Do not modify this object (move, show, hide, del, etc.)
                     after set.

        """
        def __get__(self):
            cdef Evas_Object *obj = <Evas_Object *>elm_map_overlay_content_get(self.overlay)
            return object_from_instance(obj)

        def __set__(self, Object content):
            elm_map_overlay_content_set(self.overlay, content.obj)

    def content_set(self, Object content):
        elm_map_overlay_content_set(self.overlay, content.obj)
    def content_get(self):
        cdef Evas_Object *obj = <Evas_Object *>elm_map_overlay_content_get(self.overlay)
        return object_from_instance(obj)

    property icon:
        """ The icon that is used to display the overlay.

        :type: :py:class:`efl.evas.Object`

        .. note:: Only `default` and `class` type overlay support this function.
        .. warning:: Do not modify this object (move, show, hide, del, etc.)
                     after set.
        """
        def __get__(self):
            cdef Evas_Object *obj = <Evas_Object *>elm_map_overlay_icon_get(self.overlay)
            return object_from_instance(obj)

        def __set__(self, Object icon):
            elm_map_overlay_icon_set(self.overlay, icon.obj)

    def icon_set(self, Object icon):
        elm_map_overlay_icon_set(self.overlay, icon.obj)
    def icon_get(self):
        cdef Evas_Object *obj = <Evas_Object *>elm_map_overlay_icon_get(self.overlay)
        return object_from_instance(obj)

    property region:
        """ The geographic coordinates of the overlay.

        This represent  the center coordinates of the overlay.

        :type: tuple of float (lon, lat)

        .. note:: Only `default` and `bubble` type overlay support this function.

        """
        def __get__(self):
            cdef double lon, lat
            elm_map_overlay_region_get(self.overlay, &lon, &lat)
            return (lon, lat)

        def __set__(self, value):
            lon, lat = value
            elm_map_overlay_region_set(self.overlay, lon, lat)

    def region_set(self, lon, lat):
        elm_map_overlay_region_set(self.overlay, lon, lat)
    def region_get(self):
        cdef double lon, lat
        elm_map_overlay_region_get(self.overlay, &lon, &lat)
        return (lon, lat)

    property color:
        """ The color of the overlay.

        It uses an additive color model, so each color channel represents
        how much of each primary colors must to be used. 0 represents
        absence of this color, so if all of the three are set to 0,
        the color will be black.

        These component values should be integers in the range 0 to 255,
        (single 8-bit byte).

        By default is set to solid red (r = 255, g = 0, b = 0, a = 255).

        For alpha channel, 0 represents completely transparent, and 255, opaque.

        :type: tuple of 4 int (red, green, blue, alpha)

        .. note:: Only `default`, `class` and `route` type overlay support
                  this function.

        """
        def __get__(self):
            cdef int r, g, b, a
            elm_map_overlay_color_get(self.overlay, &r, &g, &b, &a)
            return (r, g, b, a)

        def __set__(self, value):
            r, g, b, a = value
            elm_map_overlay_color_set(self.overlay, r, g, b, a)

    def color_set(self, r, g, b, a):
        elm_map_overlay_color_set(self.overlay, r, g, b, a)
    def color_get(self):
        cdef int r, g, b, a
        elm_map_overlay_color_get(self.overlay, &r, &g, &b, &a)
        return (r, g, b, a)

    def show(self):
        """ Center the map on this overlay, immediately.

        This causes the map to redraw its viewport's contents to the
        region containing the given overlay's coordinates, that will be
        moved to the center of the map.

        .. seealso:: :py:func:`Map.overlays_show` if more than one overlay need
                     to be displayed

        """
        elm_map_overlay_show(self.overlay)

    def callback_clicked_set(self, func, *args, **kwargs):
        """ Set a callback to be called when the overlay is clicked.

        If the overlay is clicked, the callback `func` will be called.
        The clicked overlay is returned by callback.

        You can add callback to the `class` overlay. If one of the group
        overlays in this class is clicked, `func` will be called and
        return a virtual group overlays.

        :param func: the callback to be called
        :type func: callable

        .. note:: Any extra argument (positional or named) passed to this
                  function will be passed back in the callback.

        """
        if not callable(func):
            raise TypeError("func must be callable")
        cb_data = (func, args, kwargs)
        elm_map_overlay_get_cb_set(self.overlay, _map_overlay_get_callback,
                                                 <void *>cb_data)
        Py_INCREF(cb_data)

    def callback_clicked_unset(self, func):
        """ Unset the callback previously attached to this overlay. """
        elm_map_overlay_get_cb_set(self.overlay, NULL, NULL)
        cb_data = <object>self.cb_get_data
        self.cb_get_data = NULL
        Py_DECREF(cb_data)


cdef class MapOverlayClass(MapOverlay):
    """

    This is a *virtual* overlay type that rapreset a set of different overlays
    grouped together.

    .. seealso:: :py:func:`Map.overlay_class_add`

    """
    def __init__(self, evasObject Map):
        self.overlay = elm_map_overlay_class_add(Map.obj)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)

    def append(self, MapOverlay overlay):
        """ Add a new overlay member to the `class` overlay.

        :param overlay: the overlay to be added as a member.
        :type overlay: :py:class:`MapOverlay`

        """
        elm_map_overlay_class_append(self.overlay, overlay.overlay)

    def remove(self, MapOverlay overlay):
        """ Remove the given overlay to the overlay class.

        :param overlay: the overlay to add as member
        :type overlay: :py:class:`MapOverlay`

        """
        elm_map_overlay_class_remove(self.overlay, overlay.overlay)

    property zoom_max:
        """ the maximum zoom from where the overlay members in the class can be
        grouped.

        Overlay members in the class only will be grouped when the map
        is displayed at less than `zoom_max`.

        :type: int

        """
        def __get__(self):
            return elm_map_overlay_class_zoom_max_get(self.overlay)

        def __set__(self, zoom):
            elm_map_overlay_class_zoom_max_set(self.overlay, zoom)

    def zoom_max_set(self, zoom):
        elm_map_overlay_class_zoom_max_set(self.overlay, zoom)
    def zoom_max_get(self):
        return elm_map_overlay_class_zoom_max_get(self.overlay)

    property members:
        """ The overlay members of the class overlay.

        The group overlays are virtually overlays. Those are shown and hidden
        dynamically. You can add callback to the class overlay. If one of the
        group overlays in this class is clicked, callback will be called and
        return a virtual group overlays.

        You can change the state (hidden, paused, etc.) or set the content
        or icon of the group overlays by changing the state of the class overlay.

        :type: list of :py:class:`MapOverlay`

        .. warning:: Do not modify the group overlay itself.

        """
        def __get__(self):
            cdef Eina_List *lst
            cdef Elm_Map_Overlay *ov
            lst = elm_map_overlay_group_members_get(self.overlay)# TODO this is somehow wrong... group <> class

            ret = []
            ret_append = ret.append
            while lst:
                ov = <Elm_Map_Overlay *>lst.data
                lst = lst.next
                o = _elm_map_overlay_to_python(ov)
                if o is not None:
                    ret_append(o)
            return ret

    def members_get(self):
        return self.members


cdef class MapOverlayBubble(MapOverlay):
    """

    This overlay type has a `bubble` style. And can `follow` another overlay.

    .. note::  This overlay has a bubble style layout and icon or content can not
               be set.

    .. seealso:: :py:func:`Map.overlay_bubble_add`

    """
    def __init__(self, evasObject Map):
        self.overlay = elm_map_overlay_bubble_add(Map.obj)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)

    def follow(self, MapOverlay overlay):
        """ Follow another overlay.

        Bubble overlay will follow the parent overlay's movement (hide, show, move).

        :param overlay: another overlay to follow.
        :type overlay: :py:class:`MapOverlay`

        """
        elm_map_overlay_bubble_follow(self.overlay, overlay.overlay)

    def content_append(self, evasObject content):
        """  Add a content object to the bubble overlay.

        Added contents will be displayed inside the bubble overlay.

        :param content: The content to be added to the bubble overlay.
        :type content: :py:class:`efl.evas.Object`
        """
        elm_map_overlay_bubble_content_append(self.overlay, content.obj)

    def content_clear(self):
        """ Clear all contents inside the bubble overlay.

        This will delete all contents inside the bubble overlay.

        """
        elm_map_overlay_bubble_content_clear(self.overlay)


cdef class MapOverlayLine(MapOverlay):
    """

    This style of overlay is drawn as a simple line.

    .. seealso:: :py:func:`Map.overlay_line_add`

    """
    def __init__(self, evasObject Map, flon, flat, tlot, tlat):
        self.overlay = elm_map_overlay_line_add(Map.obj, flon, flat, tlot, tlat)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)


cdef class MapOverlayPolygon(MapOverlay):
    """

    This overlay style is represented by a polygon. The polygon is described
    by the points added using the :py:func:`region_add` method.

    At least 3 regions should be added to show the polygon overlay.

    .. seealso:: :py:func:`Map.overlay_polygon_add`

    """
    def __init__(self, evasObject Map):
        self.overlay = elm_map_overlay_polygon_add(Map.obj)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)

    def region_add(self, lon, lat):
        """ Add a  geographic coordinates  to the polygon overlay.

        :param lon: The longitude.
        :type lon: float
        :param lat: The latitude.
        :type lat: float

        """
        elm_map_overlay_polygon_region_add(self.overlay, lon, lat)


cdef class MapOverlayCircle(MapOverlay):
    """

    This style of overlay is drawn as a simple circle.

    .. seealso:: :py:func:`Map.overlay_circle_add`

    """
    def __init__(self, evasObject Map, lon, lat, radius):
        self.overlay = elm_map_overlay_circle_add(Map.obj, lon, lat, radius)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)


cdef class MapOverlayScale(MapOverlay):
    """

    The scale overlay shows the ratio of a distance on the map to
    the corresponding distance.

    .. seealso:: :py:func:`Map.overlay_scale_add`

    """
    def __init__(self, evasObject Map, x, y):
        self.overlay = elm_map_overlay_scale_add(Map.obj, x, y)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)


cdef class MapOverlayRoute(MapOverlay):
    """

    The route overlay display a :py:class:`MapRoute` graphically on the map.

    .. seealso:: :py:func:`Map.overlay_route_add`

    """
    def __init__(self, evasObject Map, MapRoute route):
        self.overlay = elm_map_overlay_route_add(Map.obj, route.route)
        elm_map_overlay_data_set(self.overlay, <void *>self)
        elm_map_overlay_del_cb_set(self.overlay, _map_overlay_del_cb, <void *>self)
        Py_INCREF(self)


cdef class Map(Object):
    """

    This is the class that actually implement the widget.

    """
    def __init__(self, evasObject parent, *args, **kwargs):
        self._set_obj(elm_map_add(parent.obj))
        self._set_properties_from_keyword_args(kwargs)

    property zoom:
        """ The zoom level of the map.

        This property will respect the limits defined by :py:attr:`zoom_min`
        and :py:attr:`zoom_max`. By default these values are 0 (world map)
        and 18 (maximum zoom).

        This property should be used when zoom mode is set to
        `ELM_MAP_ZOOM_MODE_MANUAL`. That is the default mode, and can be set
        with :py:attr:`zoom_mode`.

        :type: int

        """
        def __get__(self):
            return elm_map_zoom_get(self.obj)

        def __set__(self, zoom):
            elm_map_zoom_set(self.obj, zoom)

    def zoom_set(self, zoom):
        elm_map_zoom_set(self.obj, zoom)
    def zoom_get(self):
        return elm_map_zoom_get(self.obj)


    property zoom_mode:
        """ The zoom mode used by the map object.

        This sets the zoom mode to manual or one of the automatic levels.
        Manual (`ELM_MAP_ZOOM_MODE_MANUAL`) means that zoom is set manually by
        the :py:attr:`zoom` property and will stay at that level until changed
        by code or until zoom_mode is changed. This is the default mode.

        The Automatic modes will allow the map object to automatically
        adjust zoom mode based on properties. `ELM_MAP_ZOOM_MODE_AUTO_FIT` will
        adjust zoom so the map fits inside the scroll frame with no pixels
        outside this area. `ELM_MAP_ZOOM_MODE_AUTO_FILL` will be similar but
        ensure no pixels within the frame are left unfilled. Do not forget that
        the valid sizes are 2^zoom, consequently the map may be smaller than
        the scroller view.

        :type: int

        """
        def __get__(self):
            return elm_map_zoom_mode_get(self.obj)

        def __set__(self, mode):
            elm_map_zoom_mode_set(self.obj, mode)

    def zoom_mode_set(self, mode):
        elm_map_zoom_mode_set(self.obj, mode)
    def zoom_mode_get(self):
        return elm_map_zoom_mode_get(self.obj)


    property zoom_min:
        """ The minimum zoom of the source. """
        def __get__(self):
            return elm_map_zoom_min_get(self.obj)

        def __set__(self, zoom):
            elm_map_zoom_min_set(self.obj, zoom)

    def zoom_min_set(self, zoom):
        elm_map_zoom_min_set(self.obj, zoom)
    def zoom_min_get(self):
        return elm_map_zoom_min_get(self.obj)


    property zoom_max:
        """ The maximum zoom of the source. """
        def __get__(self):
            return elm_map_zoom_max_get(self.obj)

        def __set__(self, zoom):
            elm_map_zoom_max_set(self.obj, zoom)

    def zoom_max_set(self, zoom):
        elm_map_zoom_max_set(self.obj, zoom)
    def zoom_max_get(self):
        return elm_map_zoom_max_get(self.obj)


    property region:
        """ The current geographic coordinates of the map.

        This gets the current center coordinates of the map object. It can be
        set by :py:func:`region_bring_in()` and :py:func:`region_show()`.

        :type: tuple of float (lon, lat)

        """
        def __get__(self):
            cdef double lon, lat
            elm_map_region_get(self.obj, &lon, &lat)
            return (lon, lat)

    def region_get(self):
        cdef double lon, lat
        elm_map_region_get(self.obj, &lon, &lat)
        return (lon, lat)


    def region_bring_in(self, lon, lat):
        """ Animatedly bring in given coordinates to the center of the map.

        This causes the map to jump to the given `lon` and `lat` coordinates
        and show it (by scrolling) in the center of the viewport, if it is not
        already centered. This will use animation to do so and take a period
        of time to complete.

        :param lon: The longitude to center at
        :type lon: float
        :param lat: The latitude to center at
        :type lat: float

        .. seealso:: :py:func:`region_show()`

        """
        elm_map_region_bring_in(self.obj, lon, lat)

    def region_show(self, lon, lat):
        """ Show the given coordinates at the center of the map, *immediately*.

        This causes the map to *redraw* its viewport's contents to the
        region containing the given `lat` and `lon`, that will be moved to the
        center of the map.

        :param lon: The longitude to center at
        :type lon: float
        :param lat: The latitude to center at
        :type lat: float

        .. seealso:: :py:func:`region_bring_in()`

        """
        elm_map_region_show(self.obj, lon, lat)

    def canvas_to_region_convert(self, x, y):
        """ Convert canvas coordinates into geographic coordinates.

        This gets longitude and latitude from canvas x, y coordinates. The canvas
        coordinates mean x, y coordinate from current viewport.

        :param x: horizontal coordinate of the point to convert.
        :type x: int
        :param y: vertical coordinate of the point to convert.
        :type y: int
        :return: (lon, lat)
        :rtype: tuple of float

        .. seealso:: :py:func:`region_to_canvas_convert`

        """
        cdef double lon, lat
        elm_map_canvas_to_region_convert(self.obj, x, y, &lon, &lat)
        return (lon, lat)

    def region_to_canvas_convert(self, lon, lat):
        """ Convert geographic coordinates into canvas coordinates.

        This gets canvas x, y coordinates from longitude and latitude. The
        canvas coordinates mean x, y coordinate from current viewport.

        :param lon: The longitude to convert.
        :type lon: float
        :param lat: The latitude to convert.
        :type lat: float
        :return: (x, y)
        :rtype: tuple of int

        .. seealso:: :py:func:`canvas_to_region_convert`

        """
        cdef Evas_Coord x, y
        elm_map_region_to_canvas_convert(self.obj, lon, lat, &x, &y)
        return (x, y)


    property paused:
        """ The paused state of the map object.

        This set/get the paused state to on (**True**) or off (**False**)
        for the map.

        The default is off.

        This will stop zooming using animation, changing zoom levels will
        change instantly. This will stop any existing animations that are running.

        :type: bool

        """
        def __get__(self):
            return bool(elm_map_paused_get(self.obj))

        def __set__(self, paused):
            elm_map_paused_set(self.obj, bool(paused))

    def paused_set(self, paused):
        elm_map_paused_set(self.obj, bool(paused))
    def paused_get(self):
        return bool(elm_map_paused_get(self.obj))


    property rotate:
        """ The rotation of the map.

        Rotate (or get the rotation) of the map around the Z axis.
        The rotation is expressed using the tuple: **(degree, cx, cy)**, where
        `degree` is an angle that range from 0.0 to 360.0, while `cx` and `cy`
        are the center of rotation expressed in canvas units.

        :type: a tuple (float, int, int)

        """
        def __get__(self):
            cdef double degree
            cdef Evas_Coord cx, cy
            elm_map_rotate_get(self.obj, &degree, &cx, &cy)
            return (degree, cx, cy)

        def __set__(self, value):
            degree, cx, cy = value
            elm_map_rotate_set(self.obj, degree, cx, cy)

    def rotate_set(self, degree, cx, cy):
        elm_map_rotate_set(self.obj, degree, cx, cy)
    def rotate_get(self):
        cdef double degree
        cdef Evas_Coord cx, cy
        elm_map_rotate_get(self.obj, &degree, &cx, &cy)
        return (degree, cx, cy)


    property wheel_disabled:
        """ Mouse wheel can be used by the user to zoom in / out the map.

        This property `disable` the mouse wheel usage.

        :type: bool

        """
        def __get__(self):
            return bool(elm_map_wheel_disabled_get(self.obj))

        def __set__(self, disabled):
            elm_map_wheel_disabled_set(self.obj, bool(disabled))

    def wheel_disabled_set(self, disabled):
        elm_map_wheel_disabled_set(self.obj, bool(disabled))
    def wheel_disabled_get(self):
        return bool(elm_map_wheel_disabled_get(self.obj))


    property user_agent:
        """ The user agent used by the map object to access routing services.

        User agent is a client application implementing a network protocol used
        in communications within a client–server distributed computing system.

        The user_agent identification string will be transmitted in a header
        field *User-Agent*.

        :type: string

        """
        def __get__(self):
            return _ctouni(elm_map_user_agent_get(self.obj))

        def __set__(self, user_agent):
            if isinstance(user_agent, unicode):
                user_agent = PyUnicode_AsUTF8String(user_agent)
            elm_map_user_agent_set(self.obj,
                <const char *>user_agent if user_agent is not None else NULL)

    def user_agent_set(self, user_agent):
        if isinstance(user_agent, unicode):
            user_agent = PyUnicode_AsUTF8String(user_agent)
        elm_map_user_agent_set(self.obj,
            <const char *>user_agent if user_agent is not None else NULL)
    def user_agent_get(self):
        return _ctouni(elm_map_user_agent_get(self.obj))


    def overlay_add(self, lon, lat):
        """ Add a new overlay to the map object. This overlay has a default type.

        An overlay will be created and shown in a specific point of the map,
        defined by `lon` and `lat`.

        The created overlay has a default style layout before content or
        icon is set. If content or icon is set, those are displayed instead
        of default style layout.

        :param lon: The longitude of the overlay.
        :type lon: float
        :param lat: The latitude of the overlay.
        :type lat: float
        :return: a newly created overlay
        :rtype: :py:class:`MapOverlay`

        .. seealso:: :py:func:`overlay_bubble_add`, :py:func:`overlay_line_add`,
                      :py:func:`overlay_polygon_add`, :py:func:`overlay_circle_add`,
                      :py:func:`overlay_scale_add`, :py:func:`overlay_class_add`,
                      :py:func:`overlay_route_add`

        """
        return MapOverlay(self, lon, lat)


    property overlays:
        """ The list of all the overlays in the map object.

        This list includes group overlays also. So this can change dynamically
        while zooming and panning.

        :return: a list of all overlays
        :rtype: list of :py:class:`MapOverlay` objects

        """
        def __get__(self):
            cdef Eina_List *lst
            cdef Elm_Map_Overlay *ov
            lst = elm_map_overlays_get(self.obj)

            ret = []
            ret_append = ret.append
            while lst:
                ov = <Elm_Map_Overlay *>lst.data
                lst = lst.next
                o = _elm_map_overlay_to_python(ov)
                if o is not None:
                    ret_append(o)
            return ret

    def overlays_get(self):
        return self.overlays


    def overlays_show(self, overlays):
        """ Move and zoom the map to display a list of overlays.

        The map will be centered on the center point of the overlays in the list.
        Then the map will be zoomed in order to fit the overlays using the
        maximum zoom which allows display of all the overlays provided.

        :param overlays: the list of overlays to show
        :type overlays: list of :py:class:`MapOverlay`

        .. warning:: All the overlays in the list should belong to the same map object.

        """
        cdef Eina_List *lst

        lst = NULL
        for overlay in overlays:
            ov = <MapOverlay>overlay
            lst = eina_list_append(lst, ov.overlay)
        elm_map_overlays_show(lst)
        eina_list_free(lst)

    def overlay_bubble_add(self):
        """ Add a new bubble overlay to the map object.

        A bubble will not be displayed before geographic coordinates are set or
        any other overlays are followed.

        This overlay has a bubble style layout and icon or content can not be set.

        :return: a new bubble style overlay
        :rtype: :py:class:`MapOverlayBubble`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayBubble(self)

    def overlay_line_add(self, flon, flat, tlon, tlat):
        """ Add a new line overlay to the map object.

        This overlay has a line type.

        :param flon: The start longitude.
        :type flon: float
        :param flat: The start latitude.
        :type flat: float
        :param tlon: The end longitude.
        :type tlon: float
        :param tlat: The end latitude.
        :type tlat: float

        :return: a new line style overlay
        :rtype: :py:class:`MapOverlayLine`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayLine(self, flon, flat, tlon, tlat)

    def overlay_polygon_add(self):
        """ Add a new polygon overlay to the map object.

        This overlay has a polygon type.
        At least 3 regions should be added to show the polygon overlay.

        :return: a new polygon style overlay
        :rtype: :py:class:`MapOverlayPolygon`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayPolygon(self)

    def overlay_circle_add(self, lon, lat, radius):
        """ Add a new circle overlay to the map object.

        This overlay has a circle type.

        :param lon: The circle center longitude.
        :type lon: float
        :param lat: The circle center latitude.
        :type lat: float
        :param radius: The radius of the overlay, in pixels.
        :type radius: int
        :return: a new circle style overlay
        :rtype: :py:class:`MapOverlayCircle`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayCircle(self, lon, lat, radius)

    def overlay_scale_add(self, x, y):
        """ Add a new scale overlay to the map object.

        This overlay has a scale type.
        The scale overlay shows the ratio of a distance on the map to
        the corresponding distance.

        :param x: horizontal pixel coordinate.
        :type x: int
        :param y: vertical pixel coordinate
        :type y: int
        :return: a new scale style overlay
        :rtype: :py:class:`MapOverlayScale`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayScale(self, x, y)

    def overlay_class_add(self):
        """ Add a new class overlay to the map object.

        This overlay has a class type.
        This overlay is not shown before overlay members are appended.
        If overlay members in the same class are close, group overlays
        are created. If they are far away, group overlays are hidden.
        When group overlays are shown, they have default style layouts at first.

        You can change the state (hidden, paused, etc.) or set the content
        or icon of the group overlays by changing the state of the class overlay.
        Do not modify the group overlay itself.
        Also these changes have an influence on the overlays in the same class
        even if each overlay is alone and is not grouped.

        :return: a new class style overlay
        :rtype: :py:class:`MapOverlayClass`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayClass(self)

    def overlay_route_add(self, route):
        """ Add a new route overlay to the map object.

        This overlay has a route type.
        This overlay has a route style layout and icon or content can not be set.


        :param route: The route object to make an overlay from.
        :type route: :py:class:`efl.elementary.map.MapRoute`
        :return: a new route style overlay
        :rtype: :py:class:`MapOverlayRoute`

        .. seealso:: :py:func:`overlay_add`

        """
        return MapOverlayRoute(self, route)


    property tile_load_status:
        """ Get the information of tile load status.

        This gets the current tiles requested and the count of the loaded ones.

        :return: the number of requested and completed tiles
        :rtype: tuple of 2 int
        """
        def __get__(self):
            cdef int try_num, finish_num
            elm_map_tile_load_status_get(self.obj, &try_num, &finish_num)
            return (try_num, finish_num)

    def tile_load_status_get(self):
        cdef int try_num, finish_num
        elm_map_tile_load_status_get(self.obj, &try_num, &finish_num)
        return (try_num, finish_num)


    def sources_get(self, type):
        """ Get the names of available sources for a specific type.

        This will provide a list with all available sources for the given type.

        Default available sources of **tile** type:

        - "Mapnik"
        - "Osmarender"
        - "CycleMap"
        - "Maplint"

        Default available sources of **route** type:

        - "Yours"

        Default available sources of **name** type:

        - "Nominatim"

        :param type: the type of the source. Must be one of: `ELM_MAP_SOURCE_TYPE_TILE`,
                     `ELM_MAP_SOURCE_TYPE_ROUTE` or `ELM_MAP_SOURCE_TYPE_NAME`
        :type type: :ref:`Elm_Map_Source_Type`

        .. seealso:: :py:func:`source_set`, :py:func:`source_get`

        """
        cdef const char **lst

        i = 0
        ret = []
        lst = elm_map_sources_get(self.obj, type)
        while (lst[i]):
            ret.append(_ctouni(lst[i]))
            i += 1

        return ret

    def source_set(self, source_type, source_name):
        """ Set the current source of the map for a specific type.

        Map widget retrieves tile images that composes the map from a web service.
        This web service can be set with this method
        for `ELM_MAP_SOURCE_TYPE_TILE` type.
        A different service can return a different maps with different
        information and it can use different zoom values.

        Map widget provides route data based on a external web service.
        This web service can be set with this method
        for `ELM_MAP_SOURCE_TYPE_ROUTE` type.

        Map widget also provide geoname data based on a external web service.
        This web service can be set with this method
        for `ELM_MAP_SOURCE_TYPE_NAME` type.

        The current source can be get using elm_map_source_get().

        :param source_type: the type of the source. Must be one of: `ELM_MAP_SOURCE_TYPE_TILE`,
                            `ELM_MAP_SOURCE_TYPE_ROUTE` or `ELM_MAP_SOURCE_TYPE_NAME`
        :type source_type: :ref:`Elm_Map_Source_Type`
        :param source_name: The source to be used. Need to match one of the names
                            provided by :py:func:`sources_get`.
        :type source_name: string

        .. seealso:: :py:func:`sources_get`, :py:func:`source_get`

        """
        if isinstance(source_name, unicode):
            source_name = PyUnicode_AsUTF8String(source_name)
        elm_map_source_set(self.obj, source_type,
            <const char *>source_name if source_name is not None else NULL)

    def source_get(self, source_type):
        """ Get the name of currently used source for a specific type.

        :param source_type: the type of the source. Must be one of: `ELM_MAP_SOURCE_TYPE_TILE`,
                            `ELM_MAP_SOURCE_TYPE_ROUTE` or `ELM_MAP_SOURCE_TYPE_NAME`
        :type source_type: :ref:`Elm_Map_Source_Type`

        .. seealso:: :py:func:`sources_get`, :py:func:`source_set`
        """
        return _ctouni(elm_map_source_get(self.obj, source_type))

    def route_add(self, Elm_Map_Route_Type type, Elm_Map_Route_Method method,
                        double flon, double flat, double tlon, double tlat,
                        route_cb, *args, **kwargs):
        """ Add a new route to the map object.

        A route will be traced by point on coordinates (`flat`, `flon`)
        to point on coordinates (`tlat`, `tlon`), using the route service
        set with :py:func:`source_set`.

        It will take `type` on consideration to define the route,
        depending if the user will be walking or driving, the route may vary.
        One of `ELM_MAP_ROUTE_TYPE_MOTOCAR`, `ELM_MAP_ROUTE_TYPE_BICYCLE`,
        or `ELM_MAP_ROUTE_TYPE_FOOT` need to be used.

        Another parameter is what the route should prioritize, the minor distance
        or the less time to be spend on the route. So `method` should be one
        of `ELM_MAP_ROUTE_METHOD_SHORTEST` or `ELM_MAP_ROUTE_METHOD_FASTEST`.

        :param type: one of `ELM_MAP_ROUTE_TYPE_MOTOCAR`, `ELM_MAP_ROUTE_TYPE_BICYCLE`
                     or `ELM_MAP_ROUTE_TYPE_FOOT`
        :type type: :ref:`Elm_Map_Route_Type`
        :param method: `ELM_MAP_ROUTE_METHOD_SHORTEST` or `ELM_MAP_ROUTE_METHOD_FASTEST`
        :type method: :ref:`Elm_Map_Route_Method`
        :param flon: The start longitude.
        :type flon: float
        :param flat: The start latitude.
        :type flat: float
        :param tlon: The destination longitude.
        :type tlon: float
        :param tlat: The destination latitude.
        :type tlat: float
        :param route_cb: A function to be called when the calculation end.
        :type route_cb: callable
        :return: a new route object
        :rtype: :py:class:`MapRoute`

        .. note:: Any other arguments (positional or named) passed to the
                  function will be passed back in the `route_cb` function

        """
        return MapRoute(self, type, method, flon, flat, tlon, tlat,
                        route_cb, *args, **kwargs)

    def name_add(self, address, double lon, double lat,
                       name_cb, *args, **kwargs):
        """  Request an address or geographic coordinates (longitude, latitude)
        from a given address or geographic coordinate(longitude, latitude).

        If you want to get address from geographic coordinates, set param
        `address` to *None* and set `lon` and `lat` as you want to query.

        Instead if you want to query the geographic coordinates for a given
        address set `address` to something different than *None*.

        To get the string for this address, MapName.address_get() should be
        used after the `name_cb` callback or "name,loaded" signal is called.

        In the same way to get the longitude and latitude, MapName.region_get()
        should be used.

        :param address: The address to query, or *None* to query by coordinates
        :type address: string
        :param lon: The longitude of the point to query.
        :type lon: float
        :param lat: The latitude of the point to query.
        :type lat: float
        :param name_cb: A function to be called when the calculation end.
        :type name_cb: callable
        :return: a new name object
        :rtype: :py:class:`MapName`

        .. note:: Any other arguments (positional or named) passed to the
                  function will be passed back in the `name_cb` function

        """
        return MapName(self, address, lon, lat, name_cb, *args, **kwargs)

    # TODO elm_map_track_add

    # TODO elm_map_track_remove

    # TODO elm_map_name_search

    def callback_clicked_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "clicked" signal. """
        self._callback_add("clicked", func, *args, **kwargs)

    def callback_clicked_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("clicked", func)

    def callback_clicked_double_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "clicked,double" signal. """
        self._callback_add("clicked,double", func, *args, **kwargs)

    def callback_clicked_double_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("clicked,double", func)

    def callback_press_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "press" signal. """
        self._callback_add("press", func, *args, **kwargs)

    def callback_press_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("press", func)

    def callback_longpressed_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "longpressed" signal. """
        self._callback_add("longpressed", func, *args, **kwargs)

    def callback_longpressed_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("longpressed", func)

    def callback_scroll_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "scroll" signal. """
        self._callback_add("scroll", func, *args, **kwargs)

    def callback_scroll_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("scroll", func)

    def callback_scroll_drag_start_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "scroll,drag,start" signal. """
        self._callback_add("scroll,drag,start", func, *args, **kwargs)

    def callback_scroll_drag_start_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("scroll,drag,start", func)

    def callback_scroll_drag_stop_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "scroll,drag,stop" signal. """
        self._callback_add("scroll,drag,stop", func, *args, **kwargs)

    def callback_scroll_drag_stop_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("scroll,drag,stop", func)

    def callback_scroll_anim_start_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "scroll,anim,start" signal. """
        self._callback_add("scroll,anim,start", func, *args, **kwargs)

    def callback_scroll_anim_start_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("scroll,anim,start", func)

    def callback_scroll_anim_stop_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "scroll,anim,stop" signal. """
        self._callback_add("scroll,anim,stop", func, *args, **kwargs)

    def callback_scroll_anim_stop_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("scroll,anim,stop", func)

    def callback_zoom_start_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "zoom,start" signal. """
        self._callback_add("zoom,start", func, *args, **kwargs)

    def callback_zoom_start_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("zoom,start", func)

    def callback_zoom_stop_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "zoom,stop" signal. """
        self._callback_add("zoom,stop", func, *args, **kwargs)

    def callback_zoom_stop_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("zoom,stop", func)

    def callback_zoom_change_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "zoom,change" signal. """
        self._callback_add("zoom,change", func, *args, **kwargs)

    def callback_zoom_change_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("zoom,change", func)

    def callback_tile_load_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "tile,load" signal. """
        self._callback_add("tile,load", func, *args, **kwargs)

    def callback_tile_load_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("tile,load", func)

    def callback_tile_loaded_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "tile,loaded" signal. """
        self._callback_add("tile,loaded", func, *args, **kwargs)

    def callback_tile_loaded_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("tile,loaded", func)

    def callback_tile_loaded_fail_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "tile,loaded,fail" signal. """
        self._callback_add("tile,loaded,fail", func, *args, **kwargs)

    def callback_tile_loaded_fail_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("tile,loaded,fail", func)

    def callback_route_load_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "route,load" signal. """
        self._callback_add("route,load", func, *args, **kwargs)

    def callback_route_load_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("route,load", func)

    def callback_route_loaded_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "route,loaded" signal. """
        self._callback_add("route,loaded", func, *args, **kwargs)

    def callback_route_loaded_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("route,loaded", func)

    def callback_route_loaded_fail_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "route,loaded,fail" signal. """
        self._callback_add("route,loaded,fail", func, *args, **kwargs)

    def callback_route_loaded_fail_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("route,loaded,fail", func)

    def callback_name_load_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "name,load" signal. """
        self._callback_add("name,load", func, *args, **kwargs)

    def callback_name_load_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("name,load", func)

    def callback_name_loaded_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "name,loaded" signal. """
        self._callback_add("name,loaded", func, *args, **kwargs)

    def callback_name_loaded_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("name,loaded", func)

    def callback_name_loaded_fail_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "name,loaded,fail" signal. """
        self._callback_add("name,loaded,fail", func, *args, **kwargs)

    def callback_name_loaded_fail_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("name,loaded,fail", func)

    def callback_overlay_clicked_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "overlay,clicked" signal. """
        self._callback_add("overlay,clicked", func, *args, **kwargs)

    def callback_overlay_clicked_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("overlay,clicked", func)

    def callback_overlay_del_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "overlay,del" signal. """
        self._callback_add("overlay,del", func, *args, **kwargs)

    def callback_overlay_del_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("overlay,del", func)

    def callback_loaded_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "loaded" signal. """
        self._callback_add("loaded", func, *args, **kwargs)

    def callback_loaded_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("loaded", func)

    def callback_language_changed_add(self, func, *args, **kwargs):
        """ Add a callback to be called on the "language,changed" signal. """
        self._callback_add("language,changed", func, *args, **kwargs)

    def callback_language_changed_del(self, func):
        """ Delete a previously attached callback """
        self._callback_del("language,changed", func)

    def callback_focused_add(self, func, *args, **kwargs):
        """When the map has received focus.

        .. versionadded:: 1.8
        """
        self._callback_add("focused", func, *args, **kwargs)

    def callback_focused_del(self, func):
        self._callback_del("focused", func)

    def callback_unfocused_add(self, func, *args, **kwargs):
        """When the map has lost focus.

        .. versionadded:: 1.8
        """
        self._callback_add("unfocused", func, *args, **kwargs)

    def callback_unfocused_del(self, func):
        self._callback_del("unfocused", func)

    property scroller_policy:
        """

        .. deprecated:: 1.8
            You should combine with Scrollable class instead.

        """
        def __get__(self):
            return self.scroller_policy_get()

        def __set__(self, value):
            cdef Elm_Scroller_Policy policy_h, policy_v
            policy_h, policy_v = value
            self.scroller_policy_set(policy_h, policy_v)

    @DEPRECATED("1.8", "You should combine with Scrollable class instead.")
    def scroller_policy_set(self, policy_h, policy_v):
        elm_scroller_policy_set(self.obj, policy_h, policy_v)
    @DEPRECATED("1.8", "You should combine with Scrollable class instead.")
    def scroller_policy_get(self):
        cdef Elm_Scroller_Policy policy_h, policy_v
        elm_scroller_policy_get(self.obj, &policy_h, &policy_v)
        return (policy_h, policy_v)

    property bounce:
        """

        .. deprecated:: 1.8
            You should combine with Scrollable class instead.

        """
        def __get__(self):
            return self.bounce_get()
        def __set__(self, value):
            cdef Eina_Bool h, v
            h, v = value
            self.bounce_set(h, v)

    @DEPRECATED("1.8", "You should combine with Scrollable class instead.")
    def bounce_set(self, h, v):
        elm_scroller_bounce_set(self.obj, h, v)
    @DEPRECATED("1.8", "You should combine with Scrollable class instead.")
    def bounce_get(self):
        cdef Eina_Bool h, v
        elm_scroller_bounce_get(self.obj, &h, &v)
        return (h, v)

_object_mapping_register("Elm_Map", Map)