How to modify image or text of style of feature? - openlayers-3

In openlayers3, in the Style Object, they don't have a method of set('') and also dont have setImage() and setText(). If i want to modify the image angle or text content, do someone know how to do ?

ol.Feature#getStyle returns a ol.style.Style (or an array);
ol.style.Style#getText returns a ol.style.Text;
ol.style.Text#setText is what you want.
So can be something like:
feature.getStyle().getText().setText('new content');

Related

It there any way to set/get data in konva shape?

It there any way to set/get data in konva object?
Just like jquery use the method 'data' to set and get info,eg: $('#abc').data('id','123') !
You can use custom attributes. Just make sure they don't overlap with built-in properties.
https://konvajs.org/api/Konva.Node.html#setAttr
https://konvajs.org/api/Konva.Node.html#getAttr
// set
shape.setAttr('someData', 0);
// get
shape.getAttr('someData');

How to get coordinates of an highlighted text in Eggplant

I have a text box, the size will change, using Ctrl+a I have highlight the text in the text box, how to get the coordinates of this highlighted text? so that I can readtext() that area. Actually I tried copying the highlighted text to clip board and then to put in a variable. But if I compare with an existing text I am getting an \n for the end of the line, if I compare the text retrieved with original text , they don't match. so I am thinking of using readtext()
Please help me in this regard.
Can you try with format function. Should get rid of escape sequences.
typeText controlKey&a
typeText controlKey&c
put remoteClipboard() into yourVariable
put format("%b", yourVariable) into newVariable
Reference link: SenseTalk
how are you comparing in your scenario?
When your use "contains" in your condition you can achieve what you have expected.

Get KML style in OpenLayers 3

I need access to extracted style attributes (e.g. fill color, stroke color, etc.) for a KML file once loaded. I can't seem to find a way to access the style once the layer has been added. The myLayer.getStyle() returns a function as expected but how does one access the style attributes?
You get the styles by calling the function.
As the docs say, you should pass an ol.Feature object and a resolution value.
But it seems to return something also when you leave the parameters undefined.
var styleFn = myLayer.getStyle();
console.log(styleFn());

Format differently specific letter in a CATextLayer?

Is that possible?
If not with CATextLAyer, then how can I do that?
You can use NSMutableAttributedString in CATextLayer. You can specify different attributes like color, font to different parts of string.
The solution was to break the word to letters and combine it back with 3 different text layers.
I will try to post the function i have build for others who needs it.

Set global text color?

I know that to use color in a document you have to load the package "color". But I can only find documentation on how to define color for a given part of the document... not what I want to do. What I do want is to define a global text color, that is used per default.
Is this possible? Can anyone tell me how to do this?
If you use, for example
\color{red}
in your preamble, before \begin{document}, then the text should be red throughout your document unless you override with another \color declaration.

Resources