jeudi 26 mars 2015

OL3: GeoJSON vector layer labels are not fixed in respect to WMS layers


I have three layers on my map. 2 are from WMS service (ortofoto 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 - its an issiue in our DB):



{"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'
}))
});


an 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 wnen I zoom in or out the map. The WMS layers stas fixed in relation to echa other but the vector labels are not fixed at the point and are gently sliding away from their position.


Zoomed out:


http://ift.tt/1N549uf


Zoomed in:


http://ift.tt/1HA5KI5


Do you have any idea how to fix this?





Aucun commentaire:

Enregistrer un commentaire