[Mapbender-commits] r8946 - in trunk/mapbender/http: php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jun 30 02:45:20 PDT 2014
Author: hwbllmnn
Date: 2014-06-30 02:45:20 -0700 (Mon, 30 Jun 2014)
New Revision: 8946
Modified:
trunk/mapbender/http/php/uploadKml.php
trunk/mapbender/http/plugins/kmlTree.js
Log:
enable file upload in ff with workaround for the onload event
Modified: trunk/mapbender/http/php/uploadKml.php
===================================================================
--- trunk/mapbender/http/php/uploadKml.php 2014-06-30 08:17:28 UTC (rev 8945)
+++ trunk/mapbender/http/php/uploadKml.php 2014-06-30 09:45:20 UTC (rev 8946)
@@ -19,13 +19,13 @@
require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
require_once(dirname(__FILE__) . "/../classes/class_kml_ows.php");
-header("Content-Type: application/vnd.geo+json");
+header("Content-Type: text/plain");
$kml = new KML();
$content = file_get_contents($_FILES['kml']['tmp_name']);
try {
if(preg_match('/.kml$/', $_FILES['kml']['name'])) {
- header("Content-Type: application/vnd.geo+json");
+ header("Content-Type: text/plain");
if($kml->parseKml($content)){
$geojson = $kml->toGeoJSON();
echo $geojson;
@@ -34,7 +34,7 @@
}
}
if(preg_match('/.(json|geojson)$/', $_FILES['kml']['name'])) {
- header("Content-Type: application/vnd.geo+json");
+ header("Content-Type: text/plain");
echo $content;
}
if(preg_match('/.(xml|gpx)$/', $_FILES['kml']['name'])) {
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2014-06-30 08:17:28 UTC (rev 8945)
+++ trunk/mapbender/http/plugins/kmlTree.js 2014-06-30 09:45:20 UTC (rev 8946)
@@ -106,25 +106,28 @@
$('#mapframe1').kml({ url: $('#kml-load-tabs').find('.kmlurl').val()});
$(dlg).dialog('destroy');
});
-
+ var ifr = $('iframe[name="kml-upload-target"]')[0];
+ var onloadfun = function() {
+ ifr.onload = null;
+ var txt = $(this).contents().find('pre').text();
+ var data;
+ try {
+ data = JSON.parse(txt);
+ } catch(e) {
+ var xml = new DOMParser().parseFromString(txt, 'application/xml');
+ data = toGeoJSON.gpx(xml);
+ }
+ var kml = $('#mapframe1').data('kml');
+ var name = $('#kml-from-upload input[type="file"]').val();
+ if(name.match(/[\\]([^\\]+)/g)) {
+ name = name.match(/[\\]([^\\]+)/g);
+ }
+ name = name[name.length-1];
+ kml.addLayer(name, data);
+ $(dlg).dialog('destroy');
+ };
$('#kml-from-upload form').bind('submit', function() {
- $('iframe[name="kml-upload-target').bind('load', function() {
- $(this).unbind('load');
- var txt = $(this).contents().find('pre').text();
- var data;
- try {
- data = JSON.parse(txt);
- } catch(e) {
- var xml = new DOMParser().parseFromString(txt, 'application/xml');
- data = toGeoJSON.gpx(xml);
- }
- var kml = $('#mapframe1').data('kml');
- var name = $('#kml-from-upload input[type="file"]').val();
- name = name.match(/[\\]([^\\]+)/g);
- name = name[name.length-1];
- kml.addLayer(name, data);
- $(dlg).dialog('destroy');
- });
+ ifr.onload = onloadfun;
});
});
$KMLfolder.find("a").after($addButton);
More information about the Mapbender_commits
mailing list