Store the KML Placemark identifier
This commit is contained in:
@@ -104,6 +104,7 @@ ol.parser.KML = function(opt_options) {
|
|||||||
'Placemark': function(node, obj) {
|
'Placemark': function(node, obj) {
|
||||||
var container = {properties: {}};
|
var container = {properties: {}};
|
||||||
var sharedVertices, callback;
|
var sharedVertices, callback;
|
||||||
|
var id = node.getAttribute('id');
|
||||||
this.readChildNodes(node, container);
|
this.readChildNodes(node, container);
|
||||||
if (goog.isDef(container.track)) {
|
if (goog.isDef(container.track)) {
|
||||||
var track = container.track, j, jj;
|
var track = container.track, j, jj;
|
||||||
@@ -125,6 +126,9 @@ ol.parser.KML = function(opt_options) {
|
|||||||
container.properties['altitude'] = track.points[i].coordinates[2];
|
container.properties['altitude'] = track.points[i].coordinates[2];
|
||||||
}
|
}
|
||||||
var feature = new ol.Feature(container.properties);
|
var feature = new ol.Feature(container.properties);
|
||||||
|
if (!goog.isNull(id)) {
|
||||||
|
feature.setFeatureId(id);
|
||||||
|
}
|
||||||
var geom = track.points[i];
|
var geom = track.points[i];
|
||||||
if (geom) {
|
if (geom) {
|
||||||
sharedVertices = undefined;
|
sharedVertices = undefined;
|
||||||
@@ -150,6 +154,9 @@ ol.parser.KML = function(opt_options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
feature = new ol.Feature(container.properties);
|
feature = new ol.Feature(container.properties);
|
||||||
|
if (!goog.isNull(id)) {
|
||||||
|
feature.setFeatureId(id);
|
||||||
|
}
|
||||||
if (container.geometry) {
|
if (container.geometry) {
|
||||||
sharedVertices = undefined;
|
sharedVertices = undefined;
|
||||||
if (this.readFeaturesOptions_) {
|
if (this.readFeaturesOptions_) {
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ describe('ol.parser.kml', function() {
|
|||||||
'itself \n at the height of the underlying terrain.';
|
'itself \n at the height of the underlying terrain.';
|
||||||
expect(obj.features[0].get('description')).to.eql(description);
|
expect(obj.features[0].get('description')).to.eql(description);
|
||||||
expect(obj.features[0].get('foo')).to.eql('bar');
|
expect(obj.features[0].get('foo')).to.eql('bar');
|
||||||
|
expect(obj.features[0].getFeatureId()).to.eql('foobarbaz');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Extended data read correctly [2]', function() {
|
it('Extended data read correctly [2]', function() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd">
|
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd">
|
||||||
<Placemark>
|
<Placemark id="foobarbaz">
|
||||||
<name>Extended data placemark</name>
|
<name>Extended data placemark</name>
|
||||||
<description>Attached to the ground. Intelligently places itself
|
<description>Attached to the ground. Intelligently places itself
|
||||||
at the height of the underlying terrain.</description>
|
at the height of the underlying terrain.</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user