You are not logged in.
- Topics: Active | Unanswered
Announcement
*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***
Pages: 1
#1 2013-09-27 15:58:28
- Markovicho
- Member
- Registered: 2013-09-23
- Posts: 10
geoJSON Styling
Ist es möglich einem in geoJSON verpackten feature ein Styling zu verpassen?
Habe folgenden Code ergoogelt aber dieser zeigt leider keinerlei Wirkung :
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-180, 10],[20, 90],[180, -5],[-30, -90]
]
]
},
"style": {
"stroke-width": "3",
"fill-opacity": 0.6
},
"className": {
"baseVal": "highway_primary"
}
}Vielen Dank schonmal !!
Offline
#2 2013-09-28 09:57:46
- tyr_asd
- Member

- Registered: 2012-08-23
- Posts: 81
- Website
Re: geoJSON Styling
Meines Wissens nach gibt es dazu kein Standard, der sich durchgesetzt hat. Du spielst mit deinem Beispiel wahrscheinlich auf GeoJSON CSS an. Wobei ich aber kein Programm kenne, welches dies unterstützt.
Einen anderen Zugang wählt Github bei der Darstellung von GeoJSON: Dort können über spezielle properties zumindest das Aussehen der Marker beeinflusst werden:
marker-size - small, medium, or large
marker-color - valid RGB hex color
marker-symbol - an icon ID from the Maki project or a single alphanumeric character (a-z or 0-9)Offline
#3 2013-09-30 10:17:57
- Markovicho
- Member
- Registered: 2013-09-23
- Posts: 10
Re: geoJSON Styling
Habe eine Lösung gefunden:
// Style fuer Polygon
var polygon_style = {
fillColor : '${color}',
strokeColor : '${color}',
strokeOpacity : "0.9",
fillOpacity : "0.2"
};
geojson_layer = new OpenLayers.Layer.Vector("GeoJSON", {
projection : projLonLat,
strategies : [ new OpenLayers.Strategy.Fixed() ],
protocol : new OpenLayers.Protocol.HTTP({
url : url_geoJSON_Polygon,
format : new OpenLayers.Format.GeoJSON()
}),
styleMap :new OpenLayers.StyleMap(polygon_style)
});
map.addLayer(geojson_layer);{
"type": "Feature",
"properties": {"color": "#2EFE2E"},
"geometry": {
"type": "Point",
"coordinates": [
13.41379165649414,
52.54431222846979
]
}
}Danke trotzdem!
Last edited by Markovicho (2013-09-30 10:18:11)
Offline
Pages: 1