I have three layers on my map. Two are from a WMS service (orthophoto and green linestrings) and one is vector layer (points - yellow labels) with GeoJSON source:
OL3Source = new ol.source.GeoJSON({
//SRID: 102067
'url': mapp['maprouter']+'?act=get_layer_data&layer='+layer_id+url_params
});
The GeoJSON looks like this (there are 3 times 2 same points - it's an issue in our database):
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[-642906.776502149,-1040547.16261086]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":2}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-647061.5440096,-1036457.97874901]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":1}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-642906.776502149,-1040547.16261086]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":7}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-647061.5440096,-1036457.97874901]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":6}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-642906.776502149,-1040547.16261086]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":12}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-647061.5440096,-1036457.97874901]},"properties":{"feature_data_getter_route":"get_cf_data_overview","feature_data_container":"popup","layer_id":"celni_fotky.overview","id":11}}]}
The label is set as follows:
OL3Layer = new ol.layer.Vector({
source: OL3Source,
visible: true,
style: styles.get(layer_id)
});
where
new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 1.5],
anchorXUnits: 'fraction',
anchorYUnits: 'fraction',
src: 'images/map/photo-marker.png'
}))
});
and the view is set like this:
view: new ol.View({
center: ol.extent.getCenter(mapp['CR_feataure'].getGeometry().getExtent()),
zoom: 8,
projection: ol.proj.get('EPSG:102067')
})
The projection is enabled like this:
proj4.defs("EPSG:102067", "+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=0 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +units=m +no_defs");
The projections are all EPSG::102067. WMS is provided by MapServer. Coordinates for the vector layer are converted on geometry from lat/lon using the following query:
UPDATE cf_metadata SET geom = ST_Transform(ST_SetSRID(ST_MakePoint(degrees(lon),degrees(lat)), 4326),102067);
The problem is that when I zoom in or out of the map. The WMS layers stays fixed in relation to each other but the vector labels are not fixed at the point and are gently sliding away from their position.
Zoomed out:
Zoomed in:
Do you have any idea how to fix this?
ol.View
configuration? – ahocevar Mar 25 '15 at 8:19ol.proj.get('EPSG:102067' );
on the console, does it returnundefined
? If so, you need to define 'EPSG:102067'. Either by using proj4js, or by usingnew ol.proj.Projection('EPSG:102067', {...});
– ahocevar Mar 25 '15 at 9:56