Styling different shapes in layers - Openlayers-3

المشرف العام

Administrator
طاقم الإدارة
To add styling to Openlayers there seems to be different rules for different shapes.

I am trying to understand when to use what, but it is rather confusing and I am only able to do it with the help of examples.

For example, I have a few points generated on my map. I generated these points with GeoJSON data with the following format:

"type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:eek:gc:def:crs:OGC:1.3:CRS84" } }, "features": [{ "type": "Feature", "properties": { "OBJECTID_1": 1, "OBJECTID": 7403704, "Identifica": "0860200000002556", "Woonplaats": "Veghel", "OpenbareRu": "Rembrandtlaan", "Huisletter": null, "Huisnummer": 1, "Huisnumm_1": null, "Postcode": "5462CJ", "Controle": 1, "Naam": "Biggelaar parket", "Functie": "Productiegebonden detailhandel van parketvloeren", "Goothoogte": 9, "Bouwhoogte": 9, "Opmerkinge": null, "Bijzonderh": null, "Woningtype": null, "Label_opme": null }, "geometry": { "type": "Point", "coordinates": [5.53204822887795, 51.609252234043296, 0.0] } }, etc... I am trying to create points, polygon's and lines. What I don't understand is to why every geometry needs it's own style contructors?

I created styling for a filled point with an example:

var _myStroke = new ol.style.Stroke({ color : 'rgba(255,0,0,1.0)', width : 1, }); var _myFill = new ol.style.Fill({ color: 'rgba(255,255,255,1)' }); var circle = new ol.style.Circle({ radius: 5, fill: _myFill, stroke: _myStroke }); var puntObjectenStyle = new ol.style.Style ({ image:circle }); var puntObjectenSource= new ol.source.Vector ({ url: 'puntobjecten.json', format: new ol.format.GeoJSON() }); var puntObjecten = new ol.layer.Vector ({ source: puntObjectenSource, style: puntObjectenStyle }); The documentation on the Openlayers website doesnt even talk about the contructors ol.style.Circle, ol.style.Fill or ol.style.Stroke?

I have the following style-up for a polygon:

weight: '1.04', fillColor: '#da2122', color: '#000000', dashArray: '', opacity: '1.0', fillOpacity: '1.0', How to create the correct functions to format a polygon? And above all: how can I know?



أكثر...
 
أعلى