Merge pull request #2676 from fredj/featureoverlay-style
ol.FeatureOverlay: use the feature style if defined
This commit is contained in:
@@ -8,7 +8,10 @@ goog.require('ol.dom.Input');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
goog.require('ol.style.Circle');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
var view = new ol.View({
|
||||
center: [0, 0],
|
||||
@@ -57,6 +60,19 @@ var accuracyFeature = new ol.Feature();
|
||||
accuracyFeature.bindTo('geometry', geolocation, 'accuracyGeometry');
|
||||
|
||||
var positionFeature = new ol.Feature();
|
||||
positionFeature.setStyle(new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
radius: 6,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#3399CC'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#fff',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
}));
|
||||
|
||||
positionFeature.bindTo('geometry', geolocation, 'position')
|
||||
.transform(function() {}, function(coordinates) {
|
||||
return coordinates ? new ol.geom.Point(coordinates) : null;
|
||||
|
||||
@@ -176,9 +176,13 @@ ol.FeatureOverlay.prototype.handleMapPostCompose_ = function(event) {
|
||||
var frameState = event.frameState;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var resolution = frameState.viewState.resolution;
|
||||
var i, ii, styles;
|
||||
var i, ii, styles, featureStyleFunction;
|
||||
this.features_.forEach(function(feature) {
|
||||
styles = styleFunction(feature, resolution);
|
||||
featureStyleFunction = feature.getStyleFunction();
|
||||
styles = goog.isDef(featureStyleFunction) ?
|
||||
featureStyleFunction.call(feature, resolution) :
|
||||
styleFunction(feature, resolution);
|
||||
|
||||
if (!goog.isDefAndNotNull(styles)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user