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:
Bart van den Eijnden
2013-04-22 16:45:33 +02:00
parent d45a63ee5c
commit feb6c4c2d7
5 changed files with 58 additions and 10 deletions

View File

@@ -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();