Marc Jansen, terrestris
Andreas Hocevar, Boundless
Marc Jansen, terrestris
Andreas Hocevar, Boundless
ol.format.XMLFeature.prototype.readFeatures = function(source) {
if (ol.xml.isDocument(source)) {
return this.readFeaturesFromDocument(/** @type {Document} */ (source));
} else if (ol.xml.isNode(source)) {
return this.readFeaturesFromNode(/** @type {Node} */ (source));
} else if (goog.isString(source)) {
var doc = ol.xml.load(source);
return this.readFeaturesFromDocument(doc);
} else {
goog.asserts.fail();
return [];
}
};
… kompiliert:
l.Ga=function(a){return Kn(a)?fo(this,a):Nn(a)?this.$b(a):la(a)?(a=Rn(a),fo(this,a)):[]};
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
})
});
OpenLayers.Map
OpenLayers.Layer.Xxx
OpenLayers.Control.Yyy
ol.Map
ol.View
(2D/3D)
ol.interaction.Zzz
ol.control.Yyy
ol.layer.Xxx
ol.source.Xxx
var vectorSource = new ol.source.IGC({
urls: [
'data/igc/ClementLatour.igc' // etc.
]
});
var styleFunction = function(feature, resolution) {
// ...
return styleArray;
};
var layer = new ol.layer.Vector({
source: vectorSource,
styleFunction: styleFunction
});
// Erzeugung einer spezifischen Interaktion:
var dragAndDropInteraction = new ol.interaction.DragAndDrop({
formatConstructors: [
ol.format.GPX,
ol.format.GeoJSON // ..
]
});
// Erweitern der Standardinteraktionen &
// Erzeugung der Karte mit den Interaktionen
var interactions = ol.interaction.defaults();
var map = new ol.Map({
interactions: interactions.extend([ dragNDropInteraction ]),
// ...
}
dragAndDropInteraction.on('addfeatures', function(event) {
var vectorSource = new ol.source.Vector({
features: event.features,
projection: event.projection
});
map.getLayers().push(new ol.layer.Vector({
source: vectorSource,
style: styleFunction
}));
var view2D = map.getView().getView2D();
view2D.fitExtent(vectorSource.getExtent(), map.getSize());
});
// Clipping vor dem Rendern
imagery.on('precompose', function(event) {
var ctx = event.context;
ctx.save();
ctx.beginPath();
if (mousePosition) {
// nur den Umkreis des Mauscursors zeigen
ctx.arc(mousePosition[0], mousePosition[1], radius, 0, 2 * Math.PI);
ctx.lineWidth = 5;
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
ctx.stroke();
}
ctx.clip();
});
// Aufräumen nach dem Rendern
imagery.on('postcompose', function(event) {
var ctx = event.context;
ctx.restore();
});