Updating examples to use the new API
This commit is contained in:
@@ -5,7 +5,6 @@ goog.require('ol.expr');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.parser.GeoJSON');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.Polygon');
|
||||
@@ -25,7 +24,8 @@ ol.expr.register('resolution', function() {
|
||||
|
||||
var vector = new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
parser: new ol.parser.GeoJSON(),
|
||||
url: 'data/countries.geojson'
|
||||
}),
|
||||
style: new ol.style.Style({rules: [
|
||||
new ol.style.Rule({
|
||||
@@ -72,22 +72,3 @@ map.on(['click', 'mousemove'], function(evt) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var geojson = new ol.parser.GeoJSON();
|
||||
var url = 'data/countries.geojson';
|
||||
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, geojson, projection);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
|
||||
Reference in New Issue
Block a user