Exemple #1
0
class MapsControlPanel(ControlPanelForm):

    form_fields = FormFields(IMapsSchema)
    label = _("Maps settings")
    description = None
    form_name = _("Maps settings")

    def _on_save(self, data):
        # This ensures the change is reflected on the served javascripts
        jstool = getToolByName(self.context, 'portal_javascripts')
        jstool.cookResources()
 def __call__(self, value, *args, **kwargs):
     try:
         if isinstance(value, basestring):
             value = value.split(",", 1)
         value = (float(value[0]), float(value[1]))
     except (ValueError, TypeError):
         return _(u""" Validation failed. Coordinates must be an decimal numbers. """)
     if not (-90  <= value[0] <= 90 ):
         return _(u""" Validation failed. Latitude not in bounds [-90, 90]. """)
     if not (-180 <= value[1] <= 180):
         return _(u""" Validation failed. Longitude not in bounds [-180, 180]. """)
     return 1
Exemple #3
0
    def marker_icons(self):
        if self.properties is None:
            return {}
        icons_list = getattr(self.properties, PROPERTY_MARKERS_FIELD, None)
        if icons_list is None:
            return {}
        portal_url_tool = getToolByName(self.context, 'portal_url')
        portal_url = portal_url_tool()
        icons = []
        for icon in icons_list:
            parts = icon.split("|")
            if parts[0].strip() == "Name":
                continue
            data = {
                'name': _(parts[0].strip()).encode('utf-8'),
                'icon': "%s/%s" % (portal_url, parts[1].strip()),
                'iconSize': getSizeFromString(parts[2]),
                'iconAnchor': getSizeFromString(parts[3]),
                'infoWindowAnchor': getSizeFromString(parts[4]),
                'shadow': "%s/%s" % (portal_url, parts[5].strip()),
                'shadowSize': getSizeFromString(parts[6]),
                'infoShadowAnchor': getSizeFromString(parts[7]),
            }
            icons.append(data)

        return icons
Exemple #4
0
    def marker_icons(self):
        if self.properties is None:
            return {}
        icons_list = getattr(self.properties, PROPERTY_MARKERS_FIELD, None)
        if icons_list is None:
            return {}
        portal_url_tool = getToolByName(self.context, 'portal_url')
        portal_url = portal_url_tool()
        icons = []
        for icon in icons_list:
            parts = icon.split("|")
            if parts[0].strip() == "Name":
                continue
            data = {
                'name': _(parts[0].strip()).encode('utf-8'),
                'icon': "%s/%s" % (portal_url, parts[1].strip()),
                'iconSize': getSizeFromString(parts[2]),
                'iconAnchor': getSizeFromString(parts[3]),
                'infoWindowAnchor': getSizeFromString(parts[4]),
                'shadow': "%s/%s" % (portal_url, parts[5].strip()),
                'shadowSize': getSizeFromString(parts[6]),
                'infoShadowAnchor': getSizeFromString(parts[7]),
            }
            icons.append(data)

        return icons
Exemple #5
0
 def __call__(self, value, *args, **kwargs):
     try:
         if isinstance(value, basestring):
             value = value.split(",", 1)
         value = (float(value[0]), float(value[1]))
     except (ValueError, TypeError):
         return _(
             u""" Validation failed. Coordinates must be an decimal numbers. """
         )
     if not (-90 <= value[0] <= 90):
         return _(
             u""" Validation failed. Latitude not in bounds [-90, 90]. """)
     if not (-180 <= value[1] <= 180):
         return _(
             u""" Validation failed. Longitude not in bounds [-180, 180]. """
         )
     return 1
from zope.schema import Bool

from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary

from plone.app.controlpanel.form import ControlPanelForm

from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
from Products.CMFPlone.interfaces import IPloneSiteRoot

from Products.Maps import MapsMessageFactory as _
from Products.Maps.config import *

DEFAULT_MAPTYPE_CHOICES = SimpleVocabulary((
    SimpleTerm('roadmap', 'roadmap',
               _('label_schematic_map',
                 default=u"Schematic map")),
    SimpleTerm('satellite', 'satellite',
               _('label_satellite_map',
                 default=u"Satellite images")),
    SimpleTerm('hybrid', 'hybrid',
               _('label_satellite_schematic_map',
                 default=u"Satellite images with schematic overlay")),
    SimpleTerm('terrain', 'terrain',
               _('label_terrain_map',
                 default=u"Physical relief tiles for displaying elevation and water features (mountains, rivers, etc.)"))
))

class IMapsSchema(Interface):
#    googlemaps_keys = Tuple(
#                        title=_('label_google_maps_api_keys',
#                                default=u'Google Maps API Keys'),
Exemple #7
0
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary

from plone.app.controlpanel.form import ControlPanelForm

from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
from Products.CMFPlone.interfaces import IPloneSiteRoot

from Products.Maps import MapsMessageFactory as _
from Products.Maps.config import *
from Products.Maps.field import GoogleAPIKey

DEFAULT_MAPTYPE_CHOICES = SimpleVocabulary((
    SimpleTerm('normal', 'normal',
               _('label_schematic_map',
                 default=u"Schematic map")),
    SimpleTerm('satellite', 'satellite',
               _('label_satellite_map',
                 default=u"Satellite images")),
    SimpleTerm('hybrid', 'hybrid',
               _('label_satellite_schematic_map',
                 default=u"Satellite images with schematic overlay")),
))


class IMapsSchema(Interface):
    googlemaps_keys = Tuple(
                        title=_('label_google_maps_api_keys',
                                default=u'Google Maps API Keys'),
                        description=_('help_google_maps_api_keys',
                                      default=u"Add Google Maps API keys. "
Exemple #8
0
class IMapsSchema(Interface):
    #    googlemaps_keys = Tuple(
    #                        title=_('label_google_maps_api_keys',
    #                                default=u'Google Maps API Keys'),
    #                        description=_('help_google_maps_api_keys',
    #                                      default=u"Add Google Maps API keys. "
    #                                               "You have to use the client "
    #                                               "side url at which your site "
    #                                               "is visible."),
    #                        unique=True,
    #                        value_type=GoogleAPIKey(
    #                            title=_(u'Key'),
    #                        ),
    #                      )

    #    googleajaxsearch_keys = Tuple(
    #                        title=_('label_google_ajax_search_api_keys',
    #                                default=u'Google AJAX Search API Keys'),
    #                        description=_('help_google_ajax_search_api_keys',
    #                                      default=u"Add Google AJAX Search API "
    #                                               "keys. You have to use the "
    #                                               "client side url at which "
    #                                               "your site is visible. This "
    #                                               "key is used to search for "
    #                                               "locations which weren't "
    #                                               "found with the default "
    #                                               "geocoding from Google Maps."),
    #                        unique=True,
    #                        value_type=GoogleAPIKey(
    #                            title=_(u'Key'),
    #                        ),
    #                      )

    googlemaps_keys = TextLine(
        title=_('label_google_maps_api3_key', default=u'Google Maps API3 Key'),
        description=_('help_google_maps_api3_key',
                      default=u"Add Google Maps API key."),
        required=False,
        default=u'',
    )

    default_maptype = Choice(
        title=_('label_default_map_type', default=u'Default map type'),
        description=_('help_default_map_type',
                      default=u"Select the default map type "
                      "initially used on maps."),
        required=True,
        vocabulary=DEFAULT_MAPTYPE_CHOICES,
    )

    default_location = TextLine(
        title=_('label_default_coordinates', default=u'Default coordinates'),
        description=_('help_default_coordinated',
                      default=u"Specify the default "
                      "coordinates for new "
                      "locations."),
        default=u'0.0, 0.0',
        required=True,
    )

    show_contents = Bool(
        title=_('label_show_contents', default=u"Show contents"),
        description=_('help_show_contents',
                      default=u"Show items\' contents in map "
                      "pop-up when clicked. "
                      "Warning: may take up a lot of "
                      "room on the map area!"),
        default=True,
    )

    layers_active = Bool(
        title=_('label_layers_active', default=u"Activate layers"),
        description=_('help_layers_active', default=u""),
        default=True,
    )

    layers_use_radio = Bool(
        title=_('label_layers_use_radio',
                default=u"Use radio buttons for layers"),
        description=_('help_layers_use_radio',
                      default=u"Select only one layer in maps"),
        default=False,
    )

    search_active = Bool(
        title=_('label_search_active', default=u"Activate search interface"),
        description=_('help_search_active', default=u""),
        default=False,
    )

    change_urls = Bool(
        title=_('label_change_urls', default=u"Change urls"),
        description=_(
            'help_change_urls',
            default=
            u"If you move and zoom a map, the URL will be changed accordingly (and it can be bookmarked)"
        ),
        default=False,
    )
Exemple #9
0
from zope.schema import Bool

from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary

from plone.app.controlpanel.form import ControlPanelForm

from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
from Products.CMFPlone.interfaces import IPloneSiteRoot

from Products.Maps import MapsMessageFactory as _
from Products.Maps.config import *

DEFAULT_MAPTYPE_CHOICES = SimpleVocabulary((
    SimpleTerm('roadmap', 'roadmap',
               _('label_schematic_map', default=u"Schematic map")),
    SimpleTerm('satellite', 'satellite',
               _('label_satellite_map', default=u"Satellite images")),
    SimpleTerm(
        'hybrid', 'hybrid',
        _('label_satellite_schematic_map',
          default=u"Satellite images with schematic overlay")),
    SimpleTerm(
        'terrain', 'terrain',
        _('label_terrain_map',
          default=
          u"Physical relief tiles for displaying elevation and water features (mountains, rivers, etc.)"
          ))))


class IMapsSchema(Interface):
Exemple #10
0
 def contents(self):
     text = self.context.getText(mimetype="text/plain").strip()
     if text:
         return ({'title': _("Info"),
                  'text': self.context.getText()},)
Exemple #11
0
 def contents(self):
     text = self.context.getText(mimetype="text/plain").strip()
     if text:
         return ({'title': _("Info"), 'text': self.context.getText()}, )