Пример #1
0
 def __init__(self, context, request):
     """ init view """
     self.context = context
     self.request = request
     self.map = IMap(self.context)
     self.config = getMultiAdapter((context, request), name="maps_configuration")
     marker_icons = self.config.marker_icons
     icons = {}
     for icon in marker_icons:
         icons[icon['name']] = icon
     icons['default'] = marker_icons[0]
     self.icons = icons
Пример #2
0
class BaseMapView(BrowserView):
    def __init__(self, context, request):
        """ init view """
        self.context = context
        self.request = request
        self.map = IMap(self.context)
        self.config = getMultiAdapter((context, request), name="maps_configuration")
        marker_icons = self.config.marker_icons
        icons = {}
        for icon in marker_icons:
            icons[icon['name']] = icon
        icons['default'] = marker_icons[0]
        self.icons = icons

    def getMarkers(self):
        if self.map is None:
            return
        for x in self.map.getMarkers():
            if x.longitude is not None:
                yield IRichMarker(x)

    def iconTagForMarker(self, marker):
        icon = self.icons.get(marker.icon, None)
        if icon is None:
            icon = self.icons['default']
        tag = '<img src="%s" alt="%s"' % (icon['icon'], escape(icon['name']))
        tag = tag + ' width="%i" height="%i"' % (icon['iconSize'][0], icon['iconSize'][1])
        tag = tag + ' class="marker" />'
        return tag

    def showContents(self):
        return self.config.show_contents
Пример #3
0
 def __init__(self, context, request):
     """ init view """
     self.context = context
     self.request = request
     self.map = IMap(self.context)
     self.config = getMultiAdapter((context, request), name="maps_configuration")
     marker_icons = self.config.marker_icons
     icons = {}
     for icon in marker_icons:
         icons[icon['name']] = icon
     icons['default'] = marker_icons[0]
     self.icons = icons
Пример #4
0
class BaseMapView(BrowserView):
    def __init__(self, context, request):
        """ init view """
        self.context = context
        self.request = request
        self.map = IMap(self.context)
        self.config = getMultiAdapter((context, request), name="maps_configuration")
        marker_icons = self.config.marker_icons
        icons = {}
        for icon in marker_icons:
            icons[icon['name']] = icon
        icons['default'] = marker_icons[0]
        self.icons = icons

    def getMarkers(self):
        if self.map is None:
            return
        for x in self.map.getMarkers():
            if x.longitude is not None:
                yield IRichMarker(x)

    def iconTagForMarker(self, marker):
        icon = self.icons.get(marker.icon, None)
        if icon is None:
            icon = self.icons['default']
        tag = '<img src="%s" alt="%s"' % (icon['icon'], escape(icon['name']))
        tag = tag + ' width="%i" height="%i"' % (icon['iconSize'][0], icon['iconSize'][1])
        tag = tag + ' class="marker" />'
        return tag

    def showContents(self):
        return self.config.show_contents

    def getSavedSettings(self):
        annotations = IAnnotations(self.context)
        try:
            return annotations['Products.Maps.map_settings']
        except KeyError:
            return '{}';
Пример #5
0
 def testTopicAdaption(self):
     self.folder.invokeFactory('Topic', 'topic')
     map = IMap(self.folder.topic)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))
Пример #6
0
 def testFolderAdaption(self):
     map = IMap(self.folder)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))
Пример #7
0
 def testTopicAdaption(self):
     self.folder.invokeFactory('Topic', 'topic')
     map = IMap(self.folder.topic)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))
Пример #8
0
 def testFolderAdaption(self):
     map = IMap(self.folder)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))