On Tue, Jun 01, 2010 at 03:04:25PM +0200, Florian Lohoff wrote: > On Tue, Jun 01, 2010 at 02:15:20PM +0200, Sarah Hoffmann wrote: > > Das geht noch einfacher mit den Strategies die OpenLayers mitliefert. > > Etwa so: > > > > vector = new OpenLayers.Layer.Vector("data", { > > strategies: [new > > OpenLayers.Strategy.BBOX({ratio : 1})], > > > > protocol: new OpenLayers.Protocol.HTTP({ > > > > url: "http://www.foo.com/bar", > > > > format: new > > OpenLayers.Format.GeoJSON() > > > > }) > > > > }); > > > > Das macht dann das Nachladen automatisch, wenn die Karte bewegt oder > > gezoomt wird. > > Wie machst du das dann an die features noch styles zu haengen? So wuerden > ja die "rohen" features in die vector layer genagelt ....
Die Styles werden im GeoJOSN mitgeliefert und dann per StyleMap zugewiesen. Sprich, ein Eintrag in der GeoJOSN-Datei sieht etwa so aus: { "type": "Feature", "geometry": {"type": "Point", "coordinates": [8.545645, 47.4117363]} ,"properties": { "graphic": "circle", "name": "Bahnhof Oerlikon 781", "color": "#0ff", "bgcolor": "#000"}} Die Style-Map etwa so: var stylemap = new OpenLayers.StyleMap( {"default" : { pointRadius : 3, fillColor: "${color}", strokeColor: "${bgcolor}", graphicName: "${graphic}", label: "${name}", strokeWidth: 1 }); Mit $ markierte Variablen werden durch die 'properties' aus dem GeoJOSN ersetzt. Dann die Style-Map beim Initialisieren des Vektor-Layers übergeben: vector = new OpenLayers.Layer.Vector("data", { strategies: [new OpenLayers.Strategy.BBOX({ratio : 1})], protocol: new OpenLayers.Protocol.HTTP({ url: "http://www.foo.com/bar", format: new OpenLayers.Format.GeoJSON() }), styleMap: stylemap }); Gruss Sarah _______________________________________________ Talk-de mailing list Talk-de@openstreetmap.org http://lists.openstreetmap.org/listinfo/talk-de