[Mapbender-commits] r9175 - in trunk/mapbender: http/classes http/extensions http/php http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 19 08:14:04 PDT 2015


Author: syed
Date: 2015-03-19 08:14:04 -0700 (Thu, 19 Mar 2015)
New Revision: 9175

Modified:
   trunk/mapbender/http/classes/class_kml_ows.php
   trunk/mapbender/http/classes/class_kml_parser_ows.php
   trunk/mapbender/http/extensions/togpx.js
   trunk/mapbender/http/extensions/tokml.js
   trunk/mapbender/http/php/mb_delete_local_data.php
   trunk/mapbender/http/php/uploadKml.php
   trunk/mapbender/http/plugins/kmlTree.js
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
add default values for feature_point properties

Modified: trunk/mapbender/http/classes/class_kml_ows.php
===================================================================
--- trunk/mapbender/http/classes/class_kml_ows.php	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/classes/class_kml_ows.php	2015-03-19 15:14:04 UTC (rev 9175)
@@ -320,11 +320,6 @@
 		$e = new mb_notice("parsing finished...#placemarks: " . count($this->placemarkArray) . " (" . count($parser->placemarkArray) . ")");
 		$this->placemarkArray = $parser->placemarkArray;
 
-//		new mb_exception(print_r($this, true));
-
-//		$this->kml = $this->__toString();
-
-//		$this->updateInDb($this->kml, $this->id);
 		return true;
 	}
 
@@ -332,30 +327,10 @@
 	 * @return string the geoJSON representation of the KML.
 	 */
 	public function toGeoJSON($str) {
-		// var_dump($str);die;
-	 //    $str = "{";
 		$numberOfPlacemarks = count($this->placemarkArray);
-		// if (sizeof($this->featureCollectionMD) > 0) {
-		// 	end($this->featureCollectionMD);
-		// 	$lastKey = key($this->featureCollectionMD);
 
-		// 	$str .= "\"@context\": {  ";
-		// 	foreach ($this->featureCollectionMD as $key => $value) {
-		// 		// var_dump($str);var_dump($key);var_dump($value);
-		// 		// if ($key == end($this->featureCollectionMD)){
-		// 		if ( $key === $lastKey ){
-
-		// 			$str.= "\"".$key."\": \"".$value."\" },";
-
-		// 		}else{
-
-		// 			$str.= "\"".$key."\": \"".$value."\",";
-		// 		}
-		// 	}
-
-		// }
 		if ($numberOfPlacemarks > 0) {
-			$str .= "\"type\": \"FeatureCollection\", \"features\": [";
+			$str .= "\"features\": [";
 			for ($i=0; $i < $numberOfPlacemarks; $i++) {
 				if ($i > 0) {
 					$str .= ",";
@@ -371,31 +346,20 @@
 	}
 
 	public function createGeoJSON(){
-		// var_dump($this->placemarkArray);die;
    		$str = "{";
+		$str.= "\"type\": \"FeatureCollection\",";
+
 	    if (sizeof($this->featureCollectionMD) > 0) {
-			end($this->featureCollectionMD);
-			$lastKey = key($this->featureCollectionMD);
 
-			$str .= "\"@context\": {  ";
 			foreach ($this->featureCollectionMD as $key => $value) {
-				// var_dump($str);var_dump($key);var_dump($value);
-				// if ($key == end($this->featureCollectionMD)){
-				if ( $key === $lastKey ){
 
-					$str.= "\"".$key."\": \"".$value."\" },";
-
-				}else{
-
 					$str.= "\"".$key."\": \"".$value."\",";
-				}
 			}
 
 		}
-		// var_dump($str);die;
+
 		$completeString = $this->toGeoJSON($str);
 		return $completeString;
-		// var_dump($completeString);die;
 	}
 	private function updateInDb($kmlDoc, $kmlId) {
 		$sql = "UPDATE gui_kml SET kml_doc = $1 WHERE kml_id = $2";

Modified: trunk/mapbender/http/classes/class_kml_parser_ows.php
===================================================================
--- trunk/mapbender/http/classes/class_kml_parser_ows.php	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/classes/class_kml_parser_ows.php	2015-03-19 15:14:04 UTC (rev 9175)
@@ -258,11 +258,9 @@
 		if ($extendedData->length > 0) { // check for metadata
 
     		foreach ($extendedData as $metaData) {
-
     			$data = $metaData->getElementsByTagName('Data');
     			foreach ($data as $metadataValue) {
 
-					$test = $metadataValue->nodeValue;
 
 					foreach($metadataValue->attributes as $attribute_name => $attribute_node){
   						// * @var  DOMNode    $attribute_node

Modified: trunk/mapbender/http/extensions/togpx.js
===================================================================
--- trunk/mapbender/http/extensions/togpx.js	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/extensions/togpx.js	2015-03-19 15:14:04 UTC (rev 9175)
@@ -2,7 +2,6 @@
 var JXON = require("jxon");
 
 function togpx( geojson, options ) {
-  console.log(geojson);
   options = (function (defaults, options) {
     for (var k in defaults) {
       if (options.hasOwnProperty(k))

Modified: trunk/mapbender/http/extensions/tokml.js
===================================================================
--- trunk/mapbender/http/extensions/tokml.js	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/extensions/tokml.js	2015-03-19 15:14:04 UTC (rev 9175)
@@ -17,7 +17,7 @@
             tag('Document',
                 documentName(options) +
                 documentDescription(options) +
-                documentMetadata(geojson,options) + // add metadata to feautureCollections
+                documentMetadata(geojson,options) + // add metadata to featureCollections
                 root(geojson, options)
                ), [['xmlns', 'http://www.opengis.net/kml/2.2']]);
 };
@@ -66,14 +66,17 @@
 
 function documentMetadata(geojson,options) {
 
-    var metadata = {};
-    for(key in geojson['@context']){
+    if (geojson.type != 'Feature') {
 
-        metadata[key]= geojson['@context'][key];
-
+        var metadata = {};
+        for(var key in geojson){
+            if(key!= 'features'){
+                metadata[key]= geojson[key];
+            }
+        }
+        extendeddata(metadata);
+        return extendeddata(metadata);
     }
-    extendeddata(metadata);
-    return extendeddata(metadata);
 }
 function documentDescription(options) {
     return (options.documentDescription !== undefined) ? tag('description', options.documentDescription) : '';

Modified: trunk/mapbender/http/php/mb_delete_local_data.php
===================================================================
--- trunk/mapbender/http/php/mb_delete_local_data.php	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/php/mb_delete_local_data.php	2015-03-19 15:14:04 UTC (rev 9175)
@@ -27,12 +27,11 @@
 
 $form_target = $self;
 
-$sql = 'delete from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and fkey_user_id = $2;';
+$sql = 'Select wmc from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and fkey_user_id = $2;';
 
 $v = array($wmc_id, $user_id);
 $t = array("i", "i");
 $res = db_prep_query($sql, $v, $t);
-header("Content-Type: application/json");
 
 // if($row = db_fetch_array($res)){
 //     $wmc->createFromXml($row['wmc']);
@@ -47,4 +46,26 @@
 //     echo('{"success":false}');
 // }
 
+
+
+if($row = db_fetch_array($res)){
+    //FIXME: Diesnt work!!
+    $wmc->createFromXml($row['wmc']);
+    $wmc->generalExtensionArray['KMLS'] = null;
+    $wmc->wmc_id = $wmc_id;
+    $wmc->has_local_data = 0;
+    $wmc->local_data_public = 0;
+    $wmc->local_data_size = '0';
+    $newWmcXml = $wmc->toXml();
+    // var_dump($wmc->wmc_id);die;
+
+    if (is_int(intval($wmc->wmc_id))) {
+        $wmc->update_existing($newWmcXml, $wmc->wmc_id);
+        echo('{"success":true}');
+    }
+}
+else {
+echo('{"success":false}');
+}
+
 ?>

Modified: trunk/mapbender/http/php/uploadKml.php
===================================================================
--- trunk/mapbender/http/php/uploadKml.php	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/php/uploadKml.php	2015-03-19 15:14:04 UTC (rev 9175)
@@ -28,7 +28,7 @@
         header("Content-Type: text/plain");
         if($kml->parseKml($content)){
             $geojson  =  $kml->createGeoJSON();
-            // var_dump($geojson);die;
+
             echo $geojson;
         }else{
             echo("{}");
@@ -36,7 +36,6 @@
     }
     if(preg_match('/.(json|geojson)$/', $_FILES['kml']['name'])) {
         header("Content-Type: text/plain");
-        // var_dump($content);die;
         echo $content;
     }
     if(preg_match('/.(xml|gpx)$/', $_FILES['kml']['name'])) {

Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/plugins/kmlTree.js	2015-03-19 15:14:04 UTC (rev 9175)
@@ -131,7 +131,25 @@
                             }, {
                                 sTitle: 'size'
                             }]
-                        }).find('.exportImage').bind('click', function(event) { // add click event to the link image
+                        })
+                        .find('tr').bind('dblclick', function() {
+                            var id = $($(this).find('td')[0]).text();
+                            $.ajax({
+                                type: 'post',
+                                url: '../php/mb_load_local_data.php',
+                                data: {
+                                    id: id
+                                },
+                                success: function(data) {
+                                    var kml = $('#mapframe1').data('kml');
+                                    $.each(data, function(url, json) {
+                                        kml.addLayer(url, json.data);
+                                    });
+                                    $(dlg).dialog('destroy');
+                                }
+                            });
+                        }).end()
+                        .find('.exportImage').bind('click', function(event) { // add click event to the link image
                             // stop event propagation beacause the following bind has to catch the click events on the 'tr'
                             event.stopPropagation();
                             if ($('#dataExportDialog').dialog('isOpen') === true) {
@@ -489,24 +507,24 @@
 
                                 }
                             });
-                        })
-                        .bind('dblclick', function() {
-                            var id = $($(this).find('td')[0]).text();
-                            $.ajax({
-                                type: 'post',
-                                url: '../php/mb_load_local_data.php',
-                                data: {
-                                    id: id
-                                },
-                                success: function(data) {
-                                    var kml = $('#mapframe1').data('kml');
-                                    $.each(data, function(url, json) {
-                                        kml.addLayer(url, json.data);
-                                    });
-                                    $(dlg).dialog('destroy');
-                                }
-                            });
                         });
+                        // .bind('dblclick', function() {
+                        //     var id = $($(this).find('td')[0]).text();
+                        //     $.ajax({
+                        //         type: 'post',
+                        //         url: '../php/mb_load_local_data.php',
+                        //         data: {
+                        //             id: id
+                        //         },
+                        //         success: function(data) {
+                        //             var kml = $('#mapframe1').data('kml');
+                        //             $.each(data, function(url, json) {
+                        //                 kml.addLayer(url, json.data);
+                        //             });
+                        //             $(dlg).dialog('destroy');
+                        //         }
+                        //     });
+                        // });
                 }
             });
             $('#kml-load-tabs').tabs();
@@ -519,11 +537,12 @@
             $('#kml-load-tabs').find('button.add-kml').bind('click', function() {
                 var kml = $('#mapframe1').data('kml');
                 var title = $('#kml-load-tabs input[name="kml-new-title"]').val();
+                var version = 'v1'
                 if (title == '') {
                     return;
                 }
                 kml.addLayer(title,{
-                    uuid: UUID.genV4().toString(), created: new Date().toISOString() ,title: title, updated: new Date().toISOString(),
+                    uuid: UUID.genV4().toString(), created: new Date().toISOString() ,title: title, updated: new Date().toISOString(), version: version,
                     type: 'FeatureCollection',
                     features: []
                 });
@@ -544,9 +563,12 @@
                 }
                 var kml = $('#mapframe1').data('kml');
                 var name;
-                if(data.hasOwnProperty('@context')){
+                // check the features for properties
+                data = setFeatureAttr(data);
 
-                    name = data['@context']['title'];
+                if( data.hasOwnProperty('title') ){
+
+                    name = data['title'];
                     kml.addLayer(name, data);
                }else{
 
@@ -603,7 +625,7 @@
 
         $featureList = $("<ul />");
         $kmlEntry.append($featureList);
-        for (var i = obj.data.features.length - 1; i >= 0; --i) {
+        for (var i = obj.data.features.length - 1; i >= 0; --i) { //FIXME: for feature without the "type: FeatureCollection ",change functionallity: if (obj.data.type == "Feature") ...
             var multi = obj.data.features[i].geometry.type.match(/^Multi/i);
             var toggle = '';
             if (multi) {
@@ -752,6 +774,61 @@
 
     });
 
+    var setFeatureAttr = function(data){
+        var simpleStyleDefaults = {
+
+            "title": "",
+            "description": "",
+            "marker-size": "medium",
+            "marker-symbol": "",
+            "marker-color": "7e7e7e",
+            "stroke": "#555555",
+            "stroke-opacity": 1.0,
+            "stroke-width": 2,
+            "fill": "#555555",
+            "fill-opacity": 0.5
+        };
+
+        if (data.type == 'Feature') {
+
+            if ( Object.getOwnPropertyNames(data.properties).length === 0  || data.properties === null) {
+
+                data.properties = simplyStyleDefaults;
+
+            } else{
+
+                $.each(simpleStyleDefaults, function(index, val) {
+
+                    if ( !data.properties.hasOwnProperty(index) ){
+
+                        data.properties[index] = value;
+                    }
+
+                });
+
+            }
+
+        } else if (data.type == 'FeatureCollection') {
+            // get all features in the featureCollection and set the default properties if they are not set
+            $.each(data.features, function(index, val) {
+
+                $.each(simpleStyleDefaults, function(prop, propVal) {
+
+                    if ( !val.properties.hasOwnProperty(prop) ){
+
+                    //TODO: get index in this scope
+                        data.features[index].properties[prop] = propVal;
+                    }
+
+                });
+            });
+
+        }
+
+        return data;
+
+
+    };
 };
 
 Mapbender.events.init.register(function() {

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-03-19 15:14:04 UTC (rev 9175)
@@ -242,7 +242,7 @@
             $('#kmlTree li.kmltree-selected').removeClass('kmltree-selected');
             attributesDialog.dialog('close');
             editStyleDialog.dialog('close');
-            console.log('ende');
+
         });
         attributesDialog = $(editAttributesHtml);
         attributesDialog.dialog({
@@ -355,8 +355,16 @@
                     url = togpx(data, {simplestyle: true});
                 }
                 if(fmt === 'geojson') {
-                    console.log('dsafasdf');
-                    url = JSON.stringify(data);
+                    if (data.type != "Feature") {
+
+                        url = JSON.stringify(data);
+                    } else {
+
+                        var newFeatureJson = $.extend(true, {}, data);
+                        var jsonFeatureHeader = {"type": "FeatureCollection", "features": [newFeatureJson]};
+                        url = JSON.stringify(jsonFeatureHeader);
+                    }
+
                 }
 
                 var link = document.createElement("a");
@@ -680,10 +688,14 @@
                 var styleRows = '<h3 style="text-align:center;">Style-Data</h3><div><table class="ftr-data-tbl style-data">';//</table></div>';
                 // var divider = "<tr><th>divider</th></tr>";
 
+                console.log(feature.properties);
+
                 $.each(feature.properties, function(k, v) {
-                    if(k.match(/Mapbender:/)) return; // was soll hiermiet passieren?
-                    if ( k == "uuid" || k == "created" || k == "updated" ) {
+                    console.log(k, v);
 
+                    if(k.match(/Mapbender:/)) return;
+                    if ( k == "uuid" || k == "created" || k == "updated" || k == "version" ) {
+
                         nonEditableRows += '<tr><td>' + k + '</td><td><input disabled type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
 
                     }else if(k == "title" || k == "name" || k == "description"){
@@ -694,7 +706,7 @@
 
                         styleRows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
 
-                    } else if( k == "Area [m²]" || k == "Length [m]" ||  k == "Boundary-Length [m]" ){
+                    } else if( k == "area" || k == "boundary-length" || k == "track-length"){ // ||  k == "Boundary-Length [m]"
 
                             geometryDiv.append('<div><p class = " geometry-p "name="' + k + '">'+ k +' : ' + v + '</p></div>');
 
@@ -714,23 +726,16 @@
                     header: "ui-icon-circle-arrow-e",
                     activeHeader: "ui-icon-circle-arrow-s"
                 };
-                // $('.attrAccordion').append(nonEditableRows)
-                // .append(editableRows)
-                // .append(customRows).accordion({
-                //     collapsible: false
-                // });
+
                 $('.attrAccordion').append(nonEditableRows)
                 .append(editableRows)
                 .append(styleRows)
                 .append(customRows).accordion({
                     collapsible: false
                 });
+
                 attributesDialog.prepend(geometryDiv);
-                // attributesDialog.find('table').html("'"+editableRows+"'"+nonEditableRows+"'"+customRows);
-                // attributesDialog.find('table').append(editableRows);
-                // attributesDialog.find('table').append(nonEditableRows);
-                // $(divider).after(rows);
-                // $( '.attrAccodion' ).accordion();
+
                 attributesDialog.find('.digitize-add').bind('click', function() {
                     var newRow = $('<tr><td><input style="width:81px" type="text"></input></td><td><input style="width:100px" type="text"></input></td></tr>');
                     attributesDialog.find('.ftr-data-tbl.custom-data').append(newRow);

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-03-17 14:13:46 UTC (rev 9174)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-03-19 15:14:04 UTC (rev 9175)
@@ -423,7 +423,6 @@
         for (var i = 0; i < pts.length; ++i) {
             var pt = Proj4js.transform(this.targetProj, this.wgs84, pts[i].pos);
             geom.addPoint(pt);
-            console.log(pt);
         }
         geom.geomType = tp;
         multi.add(geom);
@@ -471,12 +470,12 @@
 
                     if (geom.geomType == 'polygon') {
 
-                        multi.e.setElement('Area [m²]', data[0]);
-                        multi.e.setElement('Boundary-Length [m]', data[1]);
+                        multi.e.setElement('area', data[0]);
+                        multi.e.setElement('boundary-length', data[1]);
 
                     } else {
 
-                        multi.e.setElement('Length [m]', data[0]);
+                        multi.e.setElement('track-length', data[0]);
                     }
 
                 },
@@ -513,10 +512,19 @@
             });
 
             if (icon == "false" || icon === false) {
-                multi.e.setElement("Mapbender:iconOffsetX", -10);
-                multi.e.setElement("Mapbender:iconOffsetY", -34);
-                multi.e.setElement("Mapbender:icon", "../img/marker/red.png");
+                multi.e.setElement("iconOffsetX", -10);
+                multi.e.setElement("iconOffsetY", -34);
+                multi.e.setElement("icon", "../img/marker/red.png");
+
             }
+                multi.e.setElement("marker-size", 34); // default value 'medium, small, large' is not allowed from canvas
+                multi.e.setElement("marker-symbol", "");
+                multi.e.setElement("marker-color", "#7e7e7e");
+                multi.e.setElement("stroke", "#555555");
+                multi.e.setElement("stroke-opacity", 1.0);
+                multi.e.setElement("stroke-width", 2);
+                multi.e.setElement("fill", "#555555");
+                multi.e.setElement("fill-opacity", 0.5);
 
             var feat = JSON.parse(multi.toString());
             itm.data.features.push(feat);
@@ -574,7 +582,6 @@
                 var json_result;
 
                 if (!data) {
-                    console.log('test');
                     self.element.trigger('kml:error', "request returned no data");
                 } else if (data.errorMessage) {
 
@@ -582,7 +589,6 @@
                 } else {
                     //listen to gpx files
                     try {
-                        // console.log(data);
                         json_string = JSON.parse(data);
                         json_result = JSON.parse(data);
                     } catch (e) {
@@ -592,9 +598,9 @@
                     }
                     var kml = $('#mapframe1').data('kml');
                     var name;
-                    if (json_result.hasOwnProperty('@context')) {
+                    if (json_result.hasOwnProperty('title')) {
 
-                        name = json_result['@context']['title'];
+                        name = json_result['title'];
                         kml.addLayer(name, json_result);
                     } else {
 
@@ -685,17 +691,26 @@
     getLayerBbox: function(url) {
         var self = this;
         var itm = this._kmls[url];
-        if (itm.data.features.length == 0) {
-            return false;
+        var bbox ;
+        if (itm.data.type == "FeatureCollection") {
+
+            if (itm.data.features.length == 0) {
+                return false;
+            }
+            bbox = this.getBbox(itm.data.features[0]);
+            $.each(itm.data.features, function(_, v) {
+                var newbox = self.getBbox(v);
+                bbox[0] = Math.min(bbox[0], newbox[0]);
+                bbox[1] = Math.min(bbox[1], newbox[1]);
+                bbox[2] = Math.max(bbox[2], newbox[2]);
+                bbox[3] = Math.max(bbox[3], newbox[3]);
+            });
+
+        } else if (itm.data.type == "Feature") {
+
+            bbox = this.getBbox(itm.data);
+
         }
-        var bbox = this.getBbox(itm.data.features[0]);
-        $.each(itm.data.features, function(_, v) {
-            var newbox = self.getBbox(v);
-            bbox[0] = Math.min(bbox[0], newbox[0]);
-            bbox[1] = Math.min(bbox[1], newbox[1]);
-            bbox[2] = Math.max(bbox[2], newbox[2]);
-            bbox[3] = Math.max(bbox[3], newbox[3]);
-        });
         return bbox;
     },
 
@@ -751,23 +766,37 @@
         }
         if (isNaN(pt.x) || isNaN(pt.y)) return;
         // is this the right place and way to fix it?
-        if (feature.properties['Mapbender:icon']) {
-            feature.properties['marker-symbol'] = feature.properties['Mapbender:icon'];
+        if (feature.properties['icon']) {
+            feature.properties['marker-symbol'] = feature.properties['icon'];
             feature.properties['marker-type'] = 'custom';
-            feature.properties['Mapbender:icon'] = null;
+            delete feature.properties['icon'];
         }
-        if (feature.properties['Mapbender:iconOffsetX']) {
-            feature.properties['marker-offset-x'] = feature.properties['Mapbender:iconOffsetX'];
-            feature.properties['Mapbender:iconOffsetX'] = null;
+        if (feature.properties['iconOffsetX']) {
+            feature.properties['marker-offset-x'] = feature.properties['iconOffsetX'];
+            delete feature.properties['iconOffsetX'];
         }
-        if (feature.properties['Mapbender:iconOffsetY']) {
-            feature.properties['marker-offset-y'] = feature.properties['Mapbender:iconOffsetY'];
-            feature.properties['Mapbender:iconOffsetY'] = null;
+        if (feature.properties['iconOffsetY']) {
+            feature.properties['marker-offset-y'] = feature.properties['iconOffsetY'];
+            delete feature.properties['iconOffsetY'];
         }
         if (feature.properties['marker-type'] === 'custom') {
             var size = 32;
             if (feature.properties['marker-size']) {
-                size = feature.properties['marker-size'];
+
+                if (feature.properties['marker-size'] === 'large') {
+                    size = 64;
+                }
+                else if (feature.properties['marker-size'] === 'small') {
+                    size = 16;
+                }
+                else if (feature.properties['marker-size'] === 'medium') {
+                    size = size;
+                }
+                else {
+
+                    size = feature.properties['marker-size'];
+
+                }
             }
             var offx = 0,
                 offy = 0;
@@ -991,22 +1020,45 @@
 
                 feats = self.cache[url][map.getSrs()];
                 if (!feats) {
-                    $.each(item.data.features, function(_, v) {
-                        self.fixupFeature(v);
-                    });
-                    $.ajax({
-                        url: '../php/transformgeojson.php?targetEPSG=' + map.getSrs(),
-                        type: 'POST',
-                        data: JSON.stringify(item.data.features),
-                        success: function(data) {
-                            if (!$.isArray(data)) {
-                                data = JSON.parse(data);
+                    // check if feature or featureCollection
+                    // feature: item.data = item.data.features;
+                    if (item.data.type != "Feature") {
+
+                        $.each(item.data.features, function(_, v) {
+                            self.fixupFeature(v);
+                        });
+                        $.ajax({
+                            url: '../php/transformgeojson.php?targetEPSG=' + map.getSrs(),
+                            type: 'POST',
+                            data: JSON.stringify(item.data.features),
+                            success: function(data) {
+                                if (!$.isArray(data)) {
+                                    data = JSON.parse(data);
+                                }
+                                self.cache[url][map.getSrs()] = data;
+                                self.render();
                             }
-                            self.cache[url][map.getSrs()] = data;
-                            self.render();
-                        }
-                    });
-                    return;
+                        });
+                        return;
+
+                    } else {
+
+                        self.fixupFeature(item.data);
+
+                        $.ajax({
+                            url: '../php/transformgeojson.php?targetEPSG=' + map.getSrs(),
+                            type: 'POST',
+                            data: JSON.stringify(item.data),
+                            success: function(data) {
+                                if (!$.isArray(data)) {
+                                    data = JSON.parse(data);
+                                }
+                                self.cache[url][map.getSrs()] = data;
+                                self.render();
+                            }
+                        });
+                        return;
+                    }
                 }
             }
 



More information about the Mapbender_commits mailing list