将KML作为文本字符串添加到OpenLayers

时间:2013-07-06 18:40:20

标签: javascript openlayers kml

我正在尝试将kml显示为矢量图层。我将它存储为Perl标量变量,但也尝试将其设置为javascript变量。我试图从这里的问题中分离出一些代码。第一个没有产生错误,但vector_layer不显示http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps4.pl

var kml_string = '<?xml version="1.0" encoding="utf-8" ?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Folder><name>scotland_one_inch_1st</name><Schema name="scotland_one_inch_1st" id="scotland_one_inch_1st"><SimpleField name="Name" type="string"></SimpleField><SimpleField name="Description" type="string"></SimpleField><SimpleField name="SHEET" type="string"></SimpleField></Schema><Placemark><name>John Thomson, Linlithgowshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Linlithgowshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8271,56.0204 -3.3023,56.0204 -3.3023,55.8149 -3.8271,55.8149</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Stirlingshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Stirlingshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.6992,56.2988 -3.6282,56.2988 -3.6282,55.8927 -4.6992,55.8927</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Berwick-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Berwick-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.9047,55.944 -2.0344,55.944 -2.0344,55.5665 -2.9047,55.5665</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Peebles-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Peebles-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.5401,55.8247 -2.9182,55.8247 -2.9182,55.403 -3.5401,55.403</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Kirkcudbright-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Kirkcudbright-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.6636,55.3226 -3.563,55.3226 -3.563,54.7662 -4.6636,54.7662</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Edinburgh Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Edinburgh Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.7407,55.9899 -2.8252,55.9899 -2.8252,55.6441 -3.7407,55.6441</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Lanarkshire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Lanarkshire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.3831,55.9402 -3.394,55.9402 -3.394,55.2893 -4.3831,55.2893</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Haddington....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Haddington....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.0132,56.0792 -2.364,56.0792 -2.364,55.8175 -3.0132,55.8175</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Orkney Islands....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Orkney Islands....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4344,59.3921 -2.3736,59.3921 -2.3736,58.6868 -3.4344,58.6868</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Roxburghshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Roxburghshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.1198,55.7047 -2.1658,55.7047 -2.1658,55.1084 -3.1198,55.1084</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Kincardine Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Kincardine Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.7564,57.1307 -2.0535,57.1307 -2.0535,56.7444 -2.7564,56.7444</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Caithness Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Caithness Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8585,58.6938 -3.024,58.6938 -3.024,58.1369 -3.8585,58.1369</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Western Isles....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Western Isles....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-7.698,58.5156 -6.1365,58.5156 -6.1365,56.7781 -7.698,56.7781</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Dumbartonshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Dumbartonshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8813,56.3316 -3.8628,56.3316 -3.8628,55.8899 -4.8813,55.8899</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Buteshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Buteshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.3982,55.9269 -4.899,55.9269 -4.899,55.424 -5.3982,55.424</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Sutherland Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Sutherland Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.4047,58.6275 -3.5972,58.6275 -3.5972,57.8487 -5.4047,57.8487</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Argyll Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Argyll Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-7.1189,56.8668 -4.5622,56.8668 -4.5622,55.2767 -7.1189,55.2767</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Selkirk Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Selkirk Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.3554,55.6913 -2.763,55.6913 -2.763,55.3408 -3.3554,55.3408</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Skye Island, &amp;#38;c....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Skye Island, &amp;#38;c....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-6.7898,57.7461 -5.648,57.7461 -5.648,56.8242 -6.7898,56.8242</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Angus Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Angus Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4065,56.9857 -2.3875,56.9857 -2.3875,56.4327 -3.4065,56.4327</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.8722,58.1262 -3.7721,58.1262 -3.7721,57.0951 -5.8722,57.0951</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Aberdeen &amp;#38; Banff Shires. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Aberdeen &amp;#38; Banff Shires. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8016,57.7065 -1.7667,57.7065 -1.7667,56.8723 -3.8016,56.8723</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Perthshire with Clackmannan....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Perthshire with Clackmannan....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8529,56.9484 -3.0572,56.9484 -3.0572,56.0796 -4.8529,56.0796</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, County of Wigtown or Shire of Galloway...</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, County of Wigtown or Shire of Galloway...</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.1864,55.0613 -4.3442,55.0613 -4.3442,54.6336 -5.1864,54.6336</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Renfrew Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Renfrew Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8985,55.9624 -4.226,55.9624 -4.226,55.6724 -4.8985,55.6724</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Fife with Kinross Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Fife with Kinross Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.7405,56.453 -2.5472,56.453 -2.5472,56.0059 -3.7405,56.0059</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Ayrshire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Ayrshire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.1242,55.8898 -3.9608,55.8898 -3.9608,54.9976 -5.1242,54.9976</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Dumfriesshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Dumfriesshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.1218,55.4606 -2.857,55.4606 -2.857,54.9645 -4.1218,54.9645</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Shetland Islands....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Shetland Islands....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.1162,60.8545 -.7347,60.8545 -.7347,59.5132 -2.1162,59.5132</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Nairn and Elgin....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Nairn and Elgin....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.0087,57.7248 -2.9907,57.7248 -2.9907,57.2932 -4.0087,57.2932</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Inverness Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Inverness Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-6.0806,57.6319 -3.4317,57.6319 -3.4317,56.6859 -6.0806,56.6859</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark></Folder></Document></kml>'; // you kml text stored as a javascript string
var kmlParser = new OpenLayers.Format.KML({extractAttributes: true});
var featurelist = kmlParser.read(kml_string);

var vector_Layer = new OpenLayers.Layer.Vector(featurelist);

这是第二次尝试。当我尝试添加控件Uncaught SyntaxError: Unexpected identifier时,它会生成select = new OpenLayers.Control.SelectFeature(vector_Layer);http://www.geos.ed.ac.uk/~s0825955/cgi-bin/maps3.pl

var vector_Layer = new OpenLayers.Layer.Vector();

function GetFeaturesFromKMLString (strKML) {
    var format = new OpenLayers.Format.KML({
       'internalProjection': myMapObject.baseLayer.projection,
        'externalProjection': new OpenLayers.Projection("EPSG:4326")
    });
    return format.read(strKML);
};

vector_Layer.addFeatures(GetFeaturesFromKMLString('<?xml version="1.0" encoding="utf-8" ?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Folder><name>scotland_one_inch_1st</name><Schema name="scotland_one_inch_1st" id="scotland_one_inch_1st"><SimpleField name="Name" type="string"></SimpleField><SimpleField name="Description" type="string"></SimpleField><SimpleField name="SHEET" type="string"></SimpleField></Schema><Placemark><name>John Thomson, Linlithgowshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Linlithgowshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8271,56.0204 -3.3023,56.0204 -3.3023,55.8149 -3.8271,55.8149</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Stirlingshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Stirlingshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.6992,56.2988 -3.6282,56.2988 -3.6282,55.8927 -4.6992,55.8927</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Berwick-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Berwick-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.9047,55.944 -2.0344,55.944 -2.0344,55.5665 -2.9047,55.5665</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Peebles-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Peebles-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.5401,55.8247 -2.9182,55.8247 -2.9182,55.403 -3.5401,55.403</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Kirkcudbright-Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Kirkcudbright-Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.6636,55.3226 -3.563,55.3226 -3.563,54.7662 -4.6636,54.7662</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Edinburgh Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Edinburgh Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.7407,55.9899 -2.8252,55.9899 -2.8252,55.6441 -3.7407,55.6441</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Lanarkshire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Lanarkshire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.3831,55.9402 -3.394,55.9402 -3.394,55.2893 -4.3831,55.2893</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Haddington....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Haddington....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.0132,56.0792 -2.364,56.0792 -2.364,55.8175 -3.0132,55.8175</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Orkney Islands....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Orkney Islands....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4344,59.3921 -2.3736,59.3921 -2.3736,58.6868 -3.4344,58.6868</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Roxburghshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Roxburghshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.1198,55.7047 -2.1658,55.7047 -2.1658,55.1084 -3.1198,55.1084</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Kincardine Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Kincardine Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.7564,57.1307 -2.0535,57.1307 -2.0535,56.7444 -2.7564,56.7444</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Caithness Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Caithness Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8585,58.6938 -3.024,58.6938 -3.024,58.1369 -3.8585,58.1369</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Western Isles....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Western Isles....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-7.698,58.5156 -6.1365,58.5156 -6.1365,56.7781 -7.698,56.7781</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Dumbartonshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Dumbartonshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8813,56.3316 -3.8628,56.3316 -3.8628,55.8899 -4.8813,55.8899</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Buteshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Buteshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.3982,55.9269 -4.899,55.9269 -4.899,55.424 -5.3982,55.424</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Sutherland Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Sutherland Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.4047,58.6275 -3.5972,58.6275 -3.5972,57.8487 -5.4047,57.8487</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Argyll Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Argyll Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-7.1189,56.8668 -4.5622,56.8668 -4.5622,55.2767 -7.1189,55.2767</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Selkirk Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Selkirk Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.3554,55.6913 -2.763,55.6913 -2.763,55.3408 -3.3554,55.3408</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Skye Island, &amp;#38;c....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Skye Island, &amp;#38;c....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-6.7898,57.7461 -5.648,57.7461 -5.648,56.8242 -6.7898,56.8242</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Angus Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Angus Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4065,56.9857 -2.3875,56.9857 -2.3875,56.4327 -3.4065,56.4327</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Ross and Cromarty Shires. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.8722,58.1262 -3.7721,58.1262 -3.7721,57.0951 -5.8722,57.0951</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Aberdeen &amp;#38; Banff Shires. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Aberdeen &amp;#38; Banff Shires. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.8016,57.7065 -1.7667,57.7065 -1.7667,56.8723 -3.8016,56.8723</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Perthshire with Clackmannan....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Perthshire with Clackmannan....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8529,56.9484 -3.0572,56.9484 -3.0572,56.0796 -4.8529,56.0796</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, County of Wigtown or Shire of Galloway...</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, County of Wigtown or Shire of Galloway...</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.1864,55.0613 -4.3442,55.0613 -4.3442,54.6336 -5.1864,54.6336</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Renfrew Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Renfrew Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.8985,55.9624 -4.226,55.9624 -4.226,55.6724 -4.8985,55.6724</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Fife with Kinross Shire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Fife with Kinross Shire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.7405,56.453 -2.5472,56.453 -2.5472,56.0059 -3.7405,56.0059</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Ayrshire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Ayrshire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-5.1242,55.8898 -3.9608,55.8898 -3.9608,54.9976 -5.1242,54.9976</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Dumfriesshire....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Dumfriesshire....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.1218,55.4606 -2.857,55.4606 -2.857,54.9645 -4.1218,54.9645</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Shetland Islands....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Shetland Islands....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-2.1162,60.8545 -.7347,60.8545 -.7347,59.5132 -2.1162,59.5132</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Nairn and Elgin....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Nairn and Elgin....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.0087,57.7248 -2.9907,57.7248 -2.9907,57.2932 -4.0087,57.2932</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>John Thomson, Northern Part of Inverness Shire. Southern Part....</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">John Thomson, Northern Part of Inverness Shire. Southern Part....</SimpleData></SchemaData></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-6.0806,57.6319 -3.4317,57.6319 -3.4317,56.6859 -6.0806,56.6859</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark></Folder></Document></kml>'))

我认为它最后应该有一个分号,但它会吐出来。

所以我想问的是你会建议我坚持哪种技术以及我需要修复什么?

编辑:添加了缺失的括号,第二个答案现在产生相同的无错误但空白的回复

1 个答案:

答案 0 :(得分:1)

我认为你错过了一个近似括号

vector_Layer.addFeatures(GetFeaturesFromKMLString(