{ "info": { "author": "Mathieu PASQUET ", "author_email": "kiorky@cryptelium.net", "bugtrack_url": null, "classifiers": [ "Framework :: Plone", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introduction\n============\nThis is a very small and lightweight integration of OpenLayers and collective.geo.mapwidget.\nIdea is to have a map content type to create full customizable maps with the collective.geo flexibility.\nAnd the final goal is to store some javascript boilerplate on a content type to initiliaze the map.\n\nAs it requires writing some javascript with OpenLayers and jquery, it is not an 'end user' solution but a convenient and flexible way to integrate OpenLayers in plone.\n\n.. contents::\n\nInstallation\n============\nJust a simple easy_install collective.geo.geopoint is enough.\nAlternatively, buildout users can install collective.geo.geopoint as part of a specific project's buildout, by having a buildout configuration such as: ::\n\n [buildout]\n ...\n eggs =\n collective.geo.mapcontent\n ...\n [instance]\n ...\n zcml =\n collective.geo.mapcontent\n\nHow to use\n===============\nIn the plone interface, just add a map.\nYour mapid is : **mapcontent**.\nThen, fill some javascript inside the content type 'javascript' text area to display the map using mapwidget::\n\n - set the box width and height\n - set the long/lat/zoom settings\n - set the layers\n\nEG::\n\n jq('#mapcontent').css('height', '1024px');\n jq('#mapcontent').css('width', '1024px');\n var coords = {lon: 0.000000, lat: 0.000000, zoom: 10};\n cgmap.state = {'default': coords, 'mapcontent': coords};\n cgmap.extendconfig(\n {layers: [function() {\n return new OpenLayers.Layer.WMS(\"OpenLayers WMS\",\n \"http://vmap0.tiles.osgeo.org/wms/vmap0\",\n {layers: 'basic'});}\n ]\n }, 'mapcontent');\n\nMapwidget will initialize the map with those settings for you.\nAnd, remember, you are working with mapwidget.\nThis one wraps OpenLayers and here are some usefull tips:\n\n - :`cgmap.config['mapcontent'].map`: the current OpenLayers map instance\n - :`cgmap.config['mapcontent'].layers`: the list of function callbacks returning a layer\n - :`cgmap.state['mapcontent']`: the current long/lat/zoom settings (js mapping).\n\nIf you need to control the map afterwards, just register something when document is ready.\nEG::\n\n // add this in the /edit js textarea\n jq(document).ready(function() {\n cgmap['config']['mapcontent'].map.DOSOMETHING();\n });\n\nCredits\n==========\nCompanies\n----------\n|makinacom|_\n\n * `Planet Makina Corpus `_\n * `Contact us `_\n\n\nAuthors\n----------\n - kiorky \n\nContributors\n------------\n\n.. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif\n.. _makinacom: http://www.makina-corpus.com\n\n\nTests\n=========\nBeing a doctest, we can tell a story here.\n\nFirst, we must perform some setup. We use the testbrowser that is shipped\nwith Five, as this provides proper Zope 2 integration. Most of the\ndocumentation, though, is in the underlying zope.testbrower package.\n\n >>> from Products.Five.testbrowser import Browser\n >>> browser = Browser()\n >>> portal_url = self.portal.absolute_url()\n\nThe following is useful when writing and debugging testbrowser tests. It lets\nus see all error messages in the error_log.\n\n >>> self.portal.error_log._ignored_exceptions = ()\n\nWith that in place, we can go to the portal front page and log in. We will\ndo this using the default user from PloneTestCase:\n\n >>> from Products.PloneTestCase.setup import portal_owner, default_password\n\nBecause add-on themes or products may remove or hide the login portlet, this test will use the login form that comes with plone.\n\n >>> browser.open(portal_url + '/login_form')\n >>> browser.getControl(name='__ac_name').value = portal_owner\n >>> browser.getControl(name='__ac_password').value = default_password\n >>> browser.getControl(name='submit').click()\n\nHere, we set the value of the fields on the login form and then simulate a\nsubmit click. We then ensure that we get the friendly logged-in message:\n\n >>> \"You are now logged in\" in browser.contents\n True\n\nFinally, let's return to the front page of our site before continuing\n\n >>> browser.open(portal_url)\n\nThe Map Content content type\n------------------------------------\nIn this section we are tesing the Map Content content type by performing\nbasic operations like adding, updadating and deleting Map Content content\nitems.\n\nAdding a new Map Content content item\n++++++++++++++++++++++++++++++++++++++++\nWe use the 'Add new' menu to add a new content item.\n\n >>> browser.getLink('Add new').click()\n >>> browser.getControl('Map Content').click()\n >>> browser.getControl(name='form.button.Add').click()\n >>> browser.getControl(name='title').value = 'Map Content Sample'\n >>> js = \"\"\"\n ... jq('#mapcontent').css('height', '1024px');\n ... jq('#mapcontent').css('width', '1024px');\n ... var coords = {lon: 0.000000, lat: 0.000000, zoom: 10};\n ... cgmap.state = {'default': coords, 'mapcontent': coords};\n ... cgmap.extendconfig(\n ... {layers: [function() {\n ... return new OpenLayers.Layer.WMS(\"OpenLayers WMS\", \"http://vmap0.tiles.osgeo.org/wms/vmap0\", {layers: 'basic'});}\n ... ]\n ... },\n ... 'mapcontent');\n ... \"\"\"\n >>> browser.getControl(name='_js').value = js\n >>> browser.getControl('Save').click()\n >>> 'Changes saved' in browser.contents\n True\n\nRendering\n+++++++++++++\nAnd we are done! We added a new 'Map Content' content item to the portal and in view mode, it will render using the mapwidget macros\n\n >>> '