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());
Related
In the Documents symbol can pass url() for displaying custom image symbol, but if my image is square and I need it to display as rounded shape, is HighCharts supporting this or I need custom css to do that?
Highcharts only gives the possibility to set custom marker symbol using url(), but under the hood that symbol occurs as an SVGImageElement, so basically it is not able to apply the for example border-radius parameter on it.
The simplest way to achieve the effect you need is by editing the image.
Also you can dynamically add the <rect> element for every symbol and set it as a clipRect of a specific image.
Best regards!
I need to render dynamic GeoJSON data to a map in iOS.
I am using react-native-maps. I was able to render the geojson to the map, but it only shows the stroke of each region and not the fill color:
How can I add a unique color to each state or region on the map?
You need to make sure that your GeoJSON has a valid fill value at geojson.features[n].properties.fill. If your GeoJSON doesn't already have that value, you can write a function to add it. For example:
const colorizedGeojson = {
...geojson,
features: geojson.features.map(feature => ({
...feature,
properties: {
...feature.properties,
fill: getColor(feature.properties.values.population)
}
})),
};
You'll have to implement your own getColor function, depending on the data you want to represent. The population value used here is just an example. Using d3 interpolation to get the color for the value you want to represent is a common choice.
Once you've added the fill property to your GeoJSON data, you can pass that object to the component. Make sure you don't pass the fillColor property to the component, as that would override the feature colors.
<Geojson geojson={colorizedGeojson} />
That's it! The react-native-maps component will render each region/country with the color you choose:
If it still relevant, you can use multiple <Geojson /> components inside <MapView> and set different fillColor prop to them depends on your condition.
Does anyone know if you are able to set the colour of the text for a vertex label in JUNG.
I'm using the Visualisation Viewer and can seem to be able to set the colour for everything else.
vv = new VisualizationViewer<String,Integer>(treeLayout, new Dimension(410,557));
Transformer<String,Paint> vertexPaint = new Transformer<String,Paint>() {
public Paint transform(String b) {
return Color.orange;
}
};
vv.setBackground(Color.white);
vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
//vv.getRenderContext().setVertexFontTransformer(vertexFont);
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller());
vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.WHITE));
The DefaultVertexLabelRenderer and the DefaultEdgeLabelRenderer extend JLabel (it is similar to the way cell renderers work in JTable and JTree).
By default, it uses the foreground color of the VisualizationViewer to draw the label text.
vv.setForegroundColor(Color.red);
will make all of your labels red.
This approach is less expensive than making all of the labels parse HTML.
Sorry that the solution is so obscure.
Additionally, since the default renderers extend JLabel, the use of html is the same as it is for JLabel. There are good online resources to show examples of using html with javax.swing. What's missing is documentation to make the connection between using html in JUNG and using html in javax.swing.
You can use HTML in the label to specify the color; an example is here: https://stackoverflow.com/a/2017576/664856
In your case,
vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.RED));
should work (if you wanted selected vertex to be Red). I tested it myself. This applies to the selected vertex.
Upon inspection of code, I would have to believe that the link I provided does correctly work for those vertices which are not selected, but I did not actually try implementing that link.
I have a pdf which I would like to use as a template to create a new pdf. The goal is to place an image inside a particular placeholder rectangle in the original pdf. The creation of the original pdf is under my control but the placeholder rectangle/bounds might be anywhere in the pdf. I am thinking of using a dummy image(of same dimensions) as the placeholder rectangle in the original pdf.
The Prawn gem supports placing an image at a given absolute/relative position within a page.
The trouble is that since the rectangle or dummy-image could be anywhere in the original pdf, I don't know what values to use for the following
pdf.image "/path/to/image", :at => [x,y] prawn call
Is there a way to get the coordinates of an image in the original pdf. My primitive understanding tells me that one would have to render the entire pdf to know this. Is that right ? If yes, what would be a good way to render pdf in memory (headless) and get the co-ordinates of various pdf objects(like bounding rectangles, images, etc).
I am not limited by language/runtime here as long as I can trigger it programmatically.
What could be other approaches to this problem ?
Not an answer (e.g. I don't know the Ruby language), but in lieu of any others, and because I can't post a comment yet, here's what I think.
If conditions stated above are true (placeholder and replacement images are exactly same size + same color model e.g. RGB 24 bps) and you control template creation (therefore you can store placeholder inside PDF uncompressed), it can be as quick and dirty as raw replacement in a file treated as byte string. E.g. placeholder filled with red, then you search for pattern (0xFF0000) x W*H and replace it with raw image data. Which, of course, you can get any way you like, e.g.:
convert my_image.jpg RGB:- | ...
If this solution is too dirty or conditions not exact, then parse page content stream for construct like
width 0 0 height x y cm
/name Do
It's not cleanest, either, but for vast number of simple page descriptions x and y are the coordinates you are looking for.
Further, if you control template creation, why don't you store additional information inside pdf as e.g. custom keys in Info dictionary, and then read them back when using the template.
I am creating a map in which i want a polygon to display two separate variables within it. Therefore I want a stripped polygon relating to both the keys from the separate factors however I have no idea on how to do this. I messed around with multiple attributes on the properties section and could get the two variables up however could see no way of making the polygon display them both.
Thank you, any help would be appreciated
This is partially manual, but you are going to have to make a separate category within one of the fields that identifies the multivariate features. You could also create a new layer that is a selection of these features. Once you have that, go to the layer properties and display the features as 'Categories - Unique values, many fields' and hit the 'Add All Values' button. Once the categories are populated select the one you are interested in and pick a hatched symbol such as 'Radiation Overlay'. Then go to the Symbol Property Editor (double-click the symbol) and modify the two layers that make up the hatched symbol. You need to adjust the color, line thickness, offset, etc. until you get it to look the way you want. Probably not as auto as you wanted, but it will satisfy display purposes.