Javascript 如何防止图像在openlayers中缩放时调整大小?
执行此操作时,我在地图上得到两个点,但当我缩放图像时,图像会变小 如何保持图像的大小不变?下面是javascript代码Javascript 如何防止图像在openlayers中缩放时调整大小?,javascript,openlayers-3,Javascript,Openlayers 3,执行此操作时,我在地图上得到两个点,但当我缩放图像时,图像会变小 如何保持图像的大小不变?下面是javascript代码 function init() { var feature_data = { "type":"FeatureCollection", "features": [{ "type":"Feature", "id":4, "geometry": {
function init() {
var feature_data = {
"type":"FeatureCollection",
"features": [{
"type":"Feature",
"id":4,
"geometry": {
"type":"Point",
"coordinates": [65.216,33.677]
},
"properties": {
"name":"Afghanistan",
"population":25067407,
"pop_0_14":47,
"pop_15_59":49.3,
"pop_60_above":3.7
}
},
{
"type":"Feature",
"id":8,
"geometry": {
"type":"Point",
"coordinates":[20.068,41.143]
},
"properties: {
"name":"Albania",
"population":3153731,
"pop_0_14":26.3,
"pop_15_59":61.4,
"pop_60_above":12.3
}
}]
};
var map = new OpenLayers.Map('map_element',{});
var wms_layer = new OpenLayers.Layer.WMS('OpenLayers WMS',
'http://vmap0.tiles.osgeo.org/wms/vmap0',
{layers: 'basic'},
{}
);
var format_geojson = new OpenLayers.Format.GeoJSON({});
var vector_strategies = new OpenLayers.Strategy.Cluster({});
var vector_layer= new OpenLayers.Layer.Vector('bar graph visualization',
{strategies: vector_strategies}
);
vector_layer.addFeatures(format_geojson.read(feature_data));
map.addLayers([wms_layer,vector_layer]);
if(!map.getCenter()) {
map.zoomToMaxExtent();
}
}
在每次缩放更改后,实际上需要在点上强制执行调整大小事件 您可以收听缩放事件和 或者,您可以收听缩放事件和
知道OpenLayers 3中的
pointRadius
变成了什么吗?我试图阻止在较新版本中调整功能的大小,但似乎在API文档中的任何位置都找不到pointRadius
(或者任何可以做相同工作的东西)。
map.events.register("zoomend", map, function() {
var currentZoom = map.getZoom();
// check for desired zoom levels
if (currentZoom == 5) {
// update the style's pointRadius
// style.pointRadius = newRadius;
// OR
// resize each individual point feature
// loop through the point features
// pointFeature.geometry.resize(scale, origin);
// and after either strategy
// redraw the point layer
} else if (currentZoom == 6) {
...
} ...
}