From 73d1bbc9e6b911401c4c7004aa626403e4a05074 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 18 Sep 2013 19:52:49 +0000 Subject: [PATCH] Width and hight of the wrmap element are now set by javascript. If browsers do not support javascript, the map text does not overflow and hide other content anymore. git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1599 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- wrmap.body.php | 4 +--- wrmap.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wrmap.body.php b/wrmap.body.php index 8bb75f1..e6e6eec 100644 --- a/wrmap.body.php +++ b/wrmap.body.php @@ -177,9 +177,7 @@ class WrBaseMap { // Create
element where the map is placed in global $wgExtensionAssetsPath; - $width_s = (isset($properties['width'])) ? (string) $properties['width'] . 'px' : '100%'; - $height_s = (isset($properties['height']) ? (string) $properties['height'] : 450) . 'px'; - $output = "
"; + $output = "
"; $output .= htmlspecialchars($json_string, ENT_NOQUOTES); $output .= "
\n"; diff --git a/wrmap.js b/wrmap.js index 2bfc787..bab462b 100644 --- a/wrmap.js +++ b/wrmap.js @@ -1,18 +1,21 @@ "use strict"; function init_wrmap(i, jq_map) { + // define constants + var EPSG4326 = new OpenLayers.Projection("EPSG:4326"); // lon/lat + var EPSG3857 = new OpenLayers.Projection("EPSG:3857"); // google + + // extract geojson from map element and clear map element's content jq_map = $(jq_map); OpenLayers.ImgPath = jq_map.attr('data-img-path'); // e.g. "/mediawiki/extensions/wrmap/openlayers/img/" var json_string = jq_map.text(); jq_map.empty(); // once parsed, remove geojson string from the map element. - - // extract, tranform and split features to layers - var EPSG4326 = new OpenLayers.Projection("EPSG:4326"); // lon/lat - var EPSG3857 = new OpenLayers.Projection("EPSG:3857"); // google var format_json = new OpenLayers.Format.JSON(); var json_js = format_json.read(json_string); var format_geojson = new OpenLayers.Format.GeoJSON(); var features_all = format_geojson.read(json_js); + + // extract, tranform and split features to layers var features_path = new Array(); var features_point = new Array(); for (var i = 0; i != features_all.length; ++i) { @@ -166,7 +169,13 @@ function init_wrmap(i, jq_map) { var lon = json_js.properties.lon; var lat = json_js.properties.lat; var zoom = json_js.properties.zoom; + var width = json_js.properties.width; + var height = json_js.properties.height; if (zoom === undefined) zoom = 10; // default zoom + if (width === undefined) width = '100%'; // default width + if (height === undefined) height = 450; // default: 450 pixel + jq_map.width(width); + jq_map.height(height); var map = new OpenLayers.Map(jq_map.context, { projection: EPSG3857, displayProjection: EPSG4326, -- 2.39.5