Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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 '{}';
Ejemplo n.º 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))
Ejemplo n.º 6
0
 def testFolderAdaption(self):
     map = IMap(self.folder)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))
Ejemplo n.º 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))
Ejemplo n.º 8
0
 def testFolderAdaption(self):
     map = IMap(self.folder)
     self.failUnless(IMap.providedBy(map))
     self.failUnless(verifyObject(IMap, map))