src/pyams_content/component/paragraph/map.py
changeset 861 36f6bb152718
child 1157 ffb751b038cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/paragraph/map.py	Wed Jul 18 15:50:14 2018 +0200
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+from pyams_content.component.paragraph.interfaces.map import have_gis
+if have_gis:
+
+    # import standard library
+
+    # import interfaces
+    from pyams_content.component.paragraph.interfaces import IParagraphFactory
+    from pyams_content.component.paragraph.interfaces.map import IMapParagraph, MAP_PARAGRAPH_NAME, have_gis, \
+        MAP_PARAGRAPH_TYPE, MAP_PARAGRAPH_RENDERERS
+
+    # import packages
+    from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory
+    from pyams_content.features.renderer import RenderersVocabulary
+    from pyams_utils.factory import factory_config
+    from pyams_utils.registry import utility_config
+    from pyams_utils.vocabulary import vocabulary_config
+    from zope.interface import implementer
+    from zope.schema.fieldproperty import FieldProperty
+
+
+    @implementer(IMapParagraph)
+    @factory_config(provided=IMapParagraph)
+    class MapParagraph(BaseParagraph):
+        """Map paragraph"""
+
+        icon_class = 'fa-map-marker'
+        icon_hint = MAP_PARAGRAPH_NAME
+
+        if have_gis:
+            gps_location = FieldProperty(IMapParagraph['gps_location'])
+            display_marker = FieldProperty(IMapParagraph['display_marker'])
+
+        renderer = FieldProperty(IMapParagraph['renderer'])
+
+
+    @utility_config(name=MAP_PARAGRAPH_TYPE, provides=IParagraphFactory)
+    class MapParagraphFactory(BaseParagraphFactory):
+        """Map paragraph factory"""
+
+        name = MAP_PARAGRAPH_NAME
+        content_type = MapParagraph
+        secondary_menu = True
+
+
+    @vocabulary_config(name=MAP_PARAGRAPH_RENDERERS)
+    class MapParagraphRenderersVocabulary(RenderersVocabulary):
+        """Map paragraph renderers vocabulary"""
+
+        content_interface = IMapParagraph