Customising extent map for dgu.
This commit is contained in:
parent
1ffe6f42d1
commit
745bed4e77
|
@ -85,6 +85,11 @@ The Dataset Extent Map provides two different map types. It defaults to 'osm' bu
|
|||
|
||||
ckan.spatial.dataset_extent_map.map_type = os
|
||||
|
||||
The Dataset Extent Map will be inserted by default at the end of the dataset page. This can be changed by supplying an alternative element_id to the default::
|
||||
|
||||
ckan.spatial.dataset_extent_map.element_id = dataset
|
||||
|
||||
|
||||
SOLR Configuration
|
||||
------------------
|
||||
|
||||
|
|
|
@ -4,7 +4,14 @@ MAP_VIEW="""
|
|||
</div>
|
||||
"""
|
||||
|
||||
PACKAGE_MAP="""
|
||||
PACKAGE_MAP_BASIC="""
|
||||
<div class="dataset-map subsection">
|
||||
<div id="dataset-map-container"></div>
|
||||
%(map_attribution)s
|
||||
</div>
|
||||
"""
|
||||
|
||||
PACKAGE_MAP_EXTENDED="""
|
||||
<hr class="cleared" />
|
||||
<div class="dataset-map subsection">
|
||||
<h3>%(title)s</h3>
|
||||
|
@ -25,6 +32,7 @@ PACKAGE_MAP_EXTRA_FOOTER="""
|
|||
$(document).ready(function(){
|
||||
CKAN.DatasetMap.map_type = '%(map_type)s';
|
||||
CKAN.DatasetMap.extent = '%(extent)s';
|
||||
CKAN.DatasetMap.element = '#%(element_id)s';
|
||||
CKAN.DatasetMap.setup();
|
||||
})
|
||||
//]]>
|
||||
|
|
|
@ -174,13 +174,6 @@ class DatasetExtentMap(SingletonPlugin):
|
|||
|
||||
def filter(self, stream):
|
||||
from pylons import request, tmpl_context as c
|
||||
map_type = config.get('ckan.spatial.dataset_extent_map.map_type', 'osm')
|
||||
if map_type == 'osm':
|
||||
js_library_links = '<script type="text/javascript" src="/ckanext/spatial/js/openlayers/OpenLayers_dataset_map.js"></script>'
|
||||
map_attribution = html.MAP_ATTRIBUTION_OSM
|
||||
elif map_type == 'os':
|
||||
js_library_links = '<script src="http://osinspiremappingprod.ordnancesurvey.co.uk/libraries/openlayers-openlayers-56e25fc/lib/OpenLayers.js" type="text/javascript"></script>'
|
||||
map_attribution = '' # done in the js instead
|
||||
|
||||
route_dict = request.environ.get('pylons.routes_dict')
|
||||
route = '%s/%s' % (route_dict.get('controller'), route_dict.get('action'))
|
||||
|
@ -189,13 +182,25 @@ class DatasetExtentMap(SingletonPlugin):
|
|||
|
||||
extent = c.pkg.extras.get('spatial',None)
|
||||
if extent:
|
||||
map_element_id = config.get('ckan.spatial.dataset_extent_map.element_id', 'dataset')
|
||||
title = config.get('ckan.spatial.dataset_extent_map.title', 'Geographic extent')
|
||||
body_html = html.PACKAGE_MAP_EXTENDED if title else html.PACKAGE_MAP_BASIC
|
||||
map_type = config.get('ckan.spatial.dataset_extent_map.map_type', 'osm')
|
||||
if map_type == 'osm':
|
||||
js_library_links = '<script type="text/javascript" src="/ckanext/spatial/js/openlayers/OpenLayers_dataset_map.js"></script>'
|
||||
map_attribution = html.MAP_ATTRIBUTION_OSM
|
||||
elif map_type == 'os':
|
||||
js_library_links = '<script src="http://osinspiremappingprod.ordnancesurvey.co.uk/libraries/openlayers-openlayers-56e25fc/lib/OpenLayers.js" type="text/javascript"></script>'
|
||||
map_attribution = '' # done in the js instead
|
||||
|
||||
data = {'extent': extent,
|
||||
'title': _('Geographic extent'),
|
||||
'title': _(title),
|
||||
'map_type': map_type,
|
||||
'js_library_links': js_library_links,
|
||||
'map_attribution': map_attribution}
|
||||
stream = stream | Transformer('body//div[@id="dataset"]')\
|
||||
.append(HTML(html.PACKAGE_MAP % data))
|
||||
'map_attribution': map_attribution,
|
||||
'element_id': map_element_id}
|
||||
stream = stream | Transformer('body//div[@id="%s"]' % map_element_id)\
|
||||
.append(HTML(body_html % data))
|
||||
stream = stream | Transformer('head')\
|
||||
.append(HTML(html.PACKAGE_MAP_EXTRA_HEADER % data))
|
||||
stream = stream | Transformer('body')\
|
||||
|
|
|
@ -44,11 +44,11 @@ CKAN.DatasetMap = function($){
|
|||
return false;
|
||||
|
||||
// Setup some sizes
|
||||
var width = $("#dataset").width();
|
||||
var width = $(CKAN.DatasetMap.element).width();
|
||||
if (width > 1024) {
|
||||
width = 1024;
|
||||
}
|
||||
var height = width/2;
|
||||
var height = ($(CKAN.DatasetMap.element).height() || width/2);
|
||||
$("#dataset-map-container").width(width);
|
||||
$("#dataset-map-container").height(height);
|
||||
|
||||
|
|
Loading…
Reference in New Issue