If you want your MapServer WMS to reproject as part of a WMS request you will need to configure your map file to say which projections are supported.
You set the default map projection for your service in the MAP
> PROJECTION
block, like:
MAP
CONFIG "PROJ_LIB" "C:/apps/gisinternals/bin/proj/SHARE"
DEBUG 3
NAME "Your_root_layer_name"
#==========================================================#
# EXTENT
# Change to appropriate min-x,min-y,max-x,max-y coordinates
# for all your data
#==========================================================#
EXTENT -8.6476 49.8639 1.76943 60.8622
PROJECTION
#Default service projection
"init=epsg:4326"
END
You set the projection that the data is in within the LAYER
> PROJECTION
block, like:
LAYER
DATA "Calabria_Reggio_Calabria3_TF_PS_TS"
EXTENT 15.6304628873 37.9166095352 16.2989955741 38.4207238629
NAME "ITA_Calabria_Reggio_Calabria3_ESA_EN_5k_psi_TS"
PROJECTION
#Projection of the data itself
"init=epsg:4258"
END
You use the METADATA
block either at the root layer to specify projections supported by the whole service, or in the individual layers to specify projections supported by that layer, like:
METADATA
"OWS_EXTENT" "15.6304628873 37.9166095352 16.2989955741 38.4207238629"
"WMS_SRS" "EPSG:4258 EPSG:3034 EPSG:3035 EPSG:3857 EPSG:4326"
END
You need to do two things:
- Decouple the event handler so that it can be triggered by another event.
- Impersonate the
ol.MapBrowserEvent
members that your event handler requires
The following code should give you an idea on how to do what you need.
var doSomething = function(evt) {
console.log('I've done it');
// do something with evt.coordinate, evt.pixel or evt.map
};
_map.on('dblclick', doSomething);
$('#simulator').on('click', function() {
doSomething({
coordinate: [0,0],
map: _map,
pixel: [100,10],
wasVirtual: true
});
});
You may also want to add a member to the event arguments that signifies the source was virtual, or truly from the map dblclick
event.
Best Answer
Short answer: The zoom of
ol.View
is not in any unit, it is just an incrementing integer id for a given resolution.Longer answer:
Zooming in OpenLayers 3 is entirely based on resolution. The resolution is the number of map units per pixel and can vary continuously between the
minResolution
andmaxResolution
. The resolution is however constrained to a set of resolutions, which the map will snap to after zoom interactions.The zoom index/number is nothing more than an enumeration of these resolutions, where
0
is the highest resolution,1
is the second and so on. So when you doview.setZoom(6)
, all you're doing is setting the resolution to the seventh constraint resolution.So what are those resolutions? It all depends on your configuration:
resolution
option, it's value is the constraint resolutionsmaxResolution
andzoomFactor
:zoomFactor
defaults to2
, but is configurablemaxResolution
is calculated as the resolution for fitting the projection's extent in 256*256 pixels, if not explicitly providedmaxResolution / Math.pow(zoomFactor, zoomLevel)
minZoom
andmaxZoom
options will limit which of these resolutions that will be usable.maxZoom
will determine how many such resolutions are calculated, ifmaxZoom
is 20 then there will be 21 resolutions. But ifminZoom
is more than 0 the firstminZoom
of those resolutions will be ignored.