Add AsyncStringFeatureParser and use plain
XMLHttpRequest in the KML example Since the content-type on github.io is application/octet-stream we need to implement an Async string based parser interface in the KML parser. Also use plain XmlHttpRequest in the example instead of jQuery Ajax since the vector-features example also uses that.
This commit is contained in:
@@ -43,8 +43,19 @@ var map = new ol.Map({
|
||||
var kml = new ol.parser.KML({
|
||||
maxDepth: 1, dimension: 2, extractStyles: true, extractAttributes: true});
|
||||
|
||||
$.ajax({
|
||||
url: 'data/kml/lines.kml'
|
||||
}).done(function(data) {
|
||||
vector.parseFeatures(data, kml, epsg4326);
|
||||
});
|
||||
var url = 'data/kml/lines.kml';
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
|
||||
/**
|
||||
* onload handler for the XHR request.
|
||||
*/
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
// this is silly to have to tell the layer the destination projection
|
||||
var projection = map.getView().getProjection();
|
||||
vector.parseFeatures(xhr.responseText, kml, epsg4326);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
|
||||
Reference in New Issue
Block a user