I have a retina image of 500x500 pixels but it has to be displayed as 250x250 on map.
If i scale the image the quality is reduced.
Is there a way we can display retina images on the openlayers 3 map.
I use this style to display images
var style = new ol.style.Style({
image: new ol.style.Icon(({
src: imagesource,
})),
});
Related
I am trying to label vector tile point features but they always gets cropped at the tile border. I have tried (among many other things) using the renderBuffer option with no success.
I am using OL 3.19 and the vector tiles are served with Geoserver 2.10RC1 and I get the same errors in my production environment as well as editing an Boundless example (http://suite.opengeo.org/docs/latest/dataadmin/vectortiles/index.html).
I think maybe the tiles are served correctly from Geoserver and that Openlayers somehow render and then slices the tiles before presentation but I am kind of stuck on this.
Any ideas?
Screenshot of the way it looks
And the code snippet:
<script>
var style_simple = new ol.style.Style({
fill: new ol.style.Fill({
color: '#ADD8E6'
}),
stroke: new ol.style.Stroke({
color: '#880000',
width: 1
}),
text: new ol.style.Text({
text:'LOREMIPSUM'})
});
function simpleStyle(feature) {
return style_simple;
}
var map = new ol.Map({
target: 'map',
view: new ol.View({
center: [0,0],
zoom: 4
}),
layers: [new ol.layer.VectorTile({
renderBuffer:50, //doesn't matter
style:simpleStyle,
source: new ol.source.VectorTile({
tilePixelRatio: 1,
tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
format: new ol.format.MVT(),
url: 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/testlayer#EPSG%3A3857#pbf/{z}/{x}/{-y}.pbf'
})
})]
});
</script>
I have the same problem with ol.layer.VectorTile and text labels.
All labels are sliced on the tile boundaries.
Full example: https://jsfiddle.net/rn3qc4ca/
I asked the openlayers developers for help: https://github.com/openlayers/ol3/issues/6275
-> This is not a bug in openlayers. The mapbox tiles really repeat the label points in neighbored tiles. If you use very big fonts the label will still be cropped.
My (unimplemented) idea is to place all labels into a separate ol.layer.Vector layer. As this type of layer is not sliced into tiles it is always printed completely.
I'm using an image (png) for the left button in NavigatorIOS and using a high resolution png which is 60x60. The menu image is rather too big. If I use size of 30x30 the menu button is blurry.
I also tried to use 60x60 and then used #2x or #3x but that didn't help.
Does anyone know how to use a high res images for button images in NavigatorIOS?
Code:
<NavigatorIOS
ref={(ref) => this._navigator = ref}
style={{flex: 1}}
navigationBarHidden={false}
tintColor={'#000'}
barTintColor = {'#D3D2DA'}
initialRoute={{
title: 'Hello World',
component: Home,
leftButtonIcon: require('./images/menu.png'),
onLeftButtonPress: () => { this._drawer.open() }
}}/>
For clustered features I would like to make the following style in OL3:
A square, and on top of it another smaller square at the right-top corner. The bigger square would hold the symbol, and the smaller square would hold the number of the clustered features.
Similar to this
Is it possible to achieve this? In the API I've seen that ol.style.Icon and ol.style.Text has anchor and offset properties, but not RegularShape...
I have eventually overcome on this problem with using a single png image which included the square AND the smaller square, too, and overlayed the dynamic text on it, like this:
var clusterStyle = [new ol.style.Style({
image: new ol.style.Icon({
src: clustericon.png
}),
text: new ol.style.Text({
text: feature.get('features').length.size.toString(),
offsetY: -18,
offsetX: 18,
font: '12px Arial',
fill: new ol.style.Fill({
color: '#fff'
}),
scale: 1
}),
zIndex: 20
}), new ol.style.Style({
image: new ol.style.Icon({
src: 'overlayicon.png'
}),
zIndex: 21
})];
You can also insert an overlay image on it. Hope it helps you anyways
there is any way use inline SVG in Icon?
var iconStyle = new ol.style.Style({
image: new ol.style.Icon( ({
src: 'img/svg.svg'
}))
});
works fine but I generate inline SVG in code
var icon = "<svg width=34 height=34 ><polyline points='17,17 17,0 13,5 17,0 21,5' fill='none' stroke='blue' stroke-width='2' transform='rotate(263,17,17)'></polyline><circle cx=17 cy=17 r=11 style='fill:rgba(51,153,102,1);' /><circle cx=17 cy=17 r=6.5 style='fill:rgba(150,150,150,1);' /></svg>";
can i use this string like a source for icon? Or there is any possible way?
You can display an overlay containing your inline SVG.
var icon = "<svg width=34 height=34 ><polyline points='17,17 17,0 13,5 17,0 21,5' fill='none' stroke='blue' stroke-width='2' transform='rotate(263,17,17)'></polyline><circle cx=17 cy=17 r=11 style='fill:rgba(51,153,102,1);' /><circle cx=17 cy=17 r=6.5 style='fill:rgba(150,150,150,1);' /></svg>";
var overlayContent = document.createElement('div');
overlayContent.innerHTML = icon;
var overlay = new ol.Overlay({
element: overlayContent,
position: [0, 0],
positioning: 'center-center'
});
map.addOverlay(overlay);
If you need to rotate your icon, you can get your overlayContent and modify his rotation like this :
overlay.getElement().style.cssText = 'transform: rotate(' + degrees + 'deg)';
I tried with an icon and put the string with "data:image/svg+xml;utf8" but there was some exception from OL3 in IE11 when I was moving my map. (Chrome was displaying everthing fine)
Anyway, using an overlay is more performant for me and I can modify the content of my icon (size, color, ...) without recreating each time an icon.
If you just need to rotate it, the ol.Style.Icon can do it on the fly; but you just need to see if there is no more bugs :)
is possible to to add an image that it rotates when I I rotate the 3D chart?
My chart is "3d scatter draggable chart"
and i add an image in this way:
events: {
load: function() {
this.renderer.image("http://maps.googleapis.com/maps/api/staticmap?center=64.775,-17&zoom=7&size=320x320&maptype=satellite", "0%", "50%", 60, 20).add();
}
},
the image must be at the top of chart, and must follow the chart.. :
http://i59.tinypic.com/25focd2.png
http://i61.tinypic.com/23ma81w.png
the black rect will be my image..
i'm going crazy, for me it is too difficult and I do not know if it is realizable.
Please help me :(