2

I have an OpenLayers map (that you can find here, use the blue search area) that reads in a KML string that is written from Perl using data from oracle. It reads the KML like this:

var vector_Layer = new OpenLayers.Layer.Vector("Search Results");

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

vector_Layer.addFeatures(GetFeaturesFromKMLString('$newkml'));

The problem I've found is that not all of the features are displayed. For example If I search for Edinburgh only the first three features are displayed from a KML with 11 features. The KML produced where you search for Edinburgh is like this:

<?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>COLLINS, Greenvile</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">The east coast of Scotland with the isles of Orkney and Shetland</SimpleData></SchemaData><Data name="ID"><value>5728</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.7676,60.8791 .1049,60.8791 .1049,55.4382 -4.7676,55.4382</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>VAN KEULEN, Johannes</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Nieuwe pascaert van de oost cust van Schotlandt beginnende van Barwyck tot aen de Orcades ylanden</SimpleData></SchemaData><Data name="ID"><value>5972</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.1645,58.6564 -.7398,58.6564 -.7398,55.7407 -4.1645,55.7407</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>WAGHENAER, Lucas, Janszoon</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Beschrijuinge van een deel vann Schottlandt van Bambourg tot Aberdein daer Edenberg de princepaele coepstat?</SimpleData></SchemaData><Data name="ID"><value>5847</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.2504,57.1679 -1.3825,57.1679 -1.3825,55.5345 -3.2504,55.5345</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>KNOX, James</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Map of the Basin of the Firth of Forth, including the Lothians, Fife, & Kinross, with parts of the adjoining Shires</SimpleData></SchemaData><Data name="ID"><value>5464</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-4.0011,56.3508 -2.3221,56.3508 -2.3221,55.5773 -4.0011,55.5773</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>BLAEU, Joan</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Fifae Vicecomitatus, The Sherifdome of Fyfe</SimpleData></SchemaData><Data name="ID"><value>6172</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.6467,56.5955 -2.4311,56.5955 -2.4311,55.9404 -3.6467,55.9404</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>MOLL, Herman</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">The Shires of Fife and Kinros by H. Moll Geographer</SimpleData></SchemaData><Data name="ID"><value>5829</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.7619,56.4995 -2.364,56.4995 -2.364,55.9376 -3.7619,55.9376</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>BLAEU, Joan and Cornelis</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Lothian and Linlitquo</SimpleData></SchemaData><Data name="ID"><value>5824</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.737,56.143 -2.405,56.143 -2.405,55.7104 -3.737,55.7104</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>COLLINS, Greenvile</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Edinburgh Firth</SimpleData></SchemaData><Data name="ID"><value>5974</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4581,56.3983 -2.4148,56.3983 -2.4148,55.8581 -3.4581,55.8581</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>THOMSON, John</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Northern part of Edinburgh Shire [2 separate sh.]</SimpleData></SchemaData><Data name="ID"><value>5501</value></Data></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>ADAIR, John</name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">A map of Mid-Lothian, survey%27d by Mr J. Adair F.R.S.</SimpleData></SchemaData><Data name="ID"><value>5469</value></Data></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></name><ExtendedData><SchemaData schemaUrl="scotland_one_inch_1st"><SimpleData name="SHEET">Firth of Forth - Fisherrow to Edgar</SimpleData></SchemaData><Data name="ID"><value>156</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>-3.4441,56.0993 -3.0092,56.0993 -3.0092,55.9221 -3.4441,55.9221</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark></Folder></Document></kml>

Has anyone had a problem like this before and do you know if it is an issue with the KML or with OpenLayers?

1
  • are you sure the output kml is valid?
    – vinayan
    Commented Aug 2, 2013 at 4:58

2 Answers 2

1

At least one issue is that you've got extranalProjection in your code rather than externalProjection.

1
  • thanks, you're right but it doesn't fix the problem Commented Jul 31, 2013 at 13:59
1

I've fixed it. It turned out that '&'s in the database were causing errors. running a perl substitution that replaces them with & fixed it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.