Draw a temporary point in geojson example

This commit is contained in:
Éric Lemoine
2013-11-22 13:58:46 +01:00
parent 95826cd3c8
commit b78bcce8ab

View File

@@ -4,6 +4,7 @@ goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.format.GeoJSON');
goog.require('ol.geom.LineString');
goog.require('ol.geom.Point');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.shape');
@@ -124,17 +125,27 @@ var vectorLayer = new ol.layer.Vector({
source: vectorSource,
styleFunction: styleFunction
});
var tmpFeature = new ol.Feature(
var tmpLineFeature = new ol.Feature(
new ol.geom.LineString([[-5e6, -5e6], [5e6, -5e6]]));
var tmpPointFeature = new ol.Feature(
new ol.geom.Point([0, 3e6]));
var tmpStyle = new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'magenta',
width: 5
})
}),
image: ol.shape.renderCircle(5,
new ol.style.Fill({
color: 'green'
}),
new ol.style.Stroke({
color: 'blue'
}))
});
vectorLayer.on('postcompose', function(event) {
var render = event.getRender();
render.drawFeature(tmpFeature, tmpStyle);
render.drawFeature(tmpLineFeature, tmpStyle);
render.drawFeature(tmpPointFeature, tmpStyle);
});
var map = new ol.Map({