OK I found solution: I had to place stylemap as option when defining specimen vector layer.
Hope all is ok now. Thank you, Adorian http://mybiosis.info On Wed, Jul 2, 2008 at 8:16 PM, Adorian Ardelean <[EMAIL PROTECTED]> wrote: > Hi, > > *Yes* the position of features on map is OK now (I initially added in the > same place only this: "projection: new OpenLayers.Projection("EPSG:4326")". > Thank you! > > However, the style map does not function yet. > > Works OK under: > specimens2 = new OpenLayers.Layer.GML("specimens", "geojson.php", {format: > OpenLayers.Format.GeoJSON, projection: new > OpenLayers.Projection("EPSG:4326"), styleMap: new > OpenLayers.StyleMap(style)}); > > but not as > var p = new OpenLayers.Format.GeoJSON({externalProjection: new > OpenLayers.Projection('EPSG:4326'),internalProjection: > map.getProjectionObject(), styleMap: new OpenLayers.StyleMap(style)}); > > Tthis is a template context styling depending on value of parameters in > GeoJSON file. > > Any quick hints? > Adorian > > > > > On Wed, Jul 2, 2008 at 3:55 PM, Eric Lemoine <[EMAIL PROTECTED]> wrote: > >> Hi. How about that: >> >> var format = new OpenLayers.Format.GeoJSON({externalProjection: new >> OpenLayers.Projection('EPSG:4326'),internalProjection: >> map.getProjectionObject()}); >> >> Note that i haven't tested this. >> >> Eric >> >> 2008/7/2, Adorian Ardelean <[EMAIL PROTECTED]>: >> > Hi, >> > >> > First of all thank you for the prompt suggestion. Worked perfectly and I >> was >> > able to include also a style to work with properties defined within >> GeoJSON >> > file: >> > * >> > specimens = new OpenLayers.Layer.GML("specimens", "geojson.php", >> {format: >> > OpenLayers.Format.GeoJSON, projection: new >> > OpenLayers.Projection("EPSG:4326"), styleMap: new >> > OpenLayers.StyleMap(style)});* >> > >> > The situation I've encountered now is that data from this layer has to >> be >> > regenerated with every zoomend event (I do some clustering on server >> side to >> > limit the number of features to less than 100 points - the return could >> be >> > easily in hundreds or more). The part with zoomend event I can handle. >> > However, I do not know what is the best strategy to handle this >> situation >> > further: >> > >> > 1. delete the whole layer and recreate a new GML layer (using code >> above) >> > every time? This produces some problems in handling controls (as I >> interpret >> > from reaction of the scripts). The controls dedicated to layer >> "specimens" >> > does not function anymore. I have to redeclare it again. >> > >> > 2. create a vector layer and load and delete features with zoom events >> > without removing layer and controls. >> > >> > For second solution I have found the piece of code below, (which also >> works) >> > but returns me to the initial question how do I specify in this context >> > projection an style parameters?: >> > >> > *OpenLayers.loadURL("geojson.php", {}, null, styleMap: new >> > OpenLayers.StyleMap(style)}, onLoadgml, onLoadFailedgml); >> > >> > function onLoadgml(r) { >> > if (r.status == 200) { >> > var p = new OpenLayers.Format.GeoJSON(); >> > var f = p.read(r.responseText); >> > specimens.addFeatures(f); >> > } >> > }* >> > * >> > .... >> > >> > *I would somehow prefer the second strategy. Could somebody give me a >> hint >> > on how to include *{format: OpenLayers.Format.GeoJSON, projection: new >> > OpenLayers.Projection("EPSG:4326")* in script so that OL renders vector >> > features at the right place*? >> > >> > *All the best, >> > Adorian >> > >> > On Sat, Jun 28, 2008 at 5:32 PM, Christopher Schmidt < >> > [EMAIL PROTECTED]> wrote: >> > >> >> On Sat, Jun 28, 2008 at 04:39:19PM +0200, Adorian Ardelean wrote: >> >> > Hi, >> >> > >> >> > I am trying to load a GeoJSON file in a layer on top of a google map >> >> > (OpenLayers 2.6). >> >> > >> >> > I used for now: >> >> > var colfeatures = new OpenLayers.Layer.GML("specimens", >> "geojson.php", >> >> > {format: OpenLayers.Format.GeoJSON}); >> >> > map.addLayer(colfeatures); >> >> > >> >> > Entities show up on the map somewhere close to 0,0. For other vector >> >> > entities (coordinates) I push through code this is solved with >> >> > >> >> > var g = new OpenLayers.Projection("EPSG:4326"); >> >> > var p = new OpenLayers.Projection("EPSG:900913"); >> >> > >> >> > and .tranform(g,p) >> >> > >> >> > but I do not know how to apply this directly on features read from >> >> GeoJSON. >> >> > Is there a way to loop through all entities in colfeatures and apply >> >> > transform(g.p) or can somebody suggest me a better approach? >> >> {format: OpenLayers.Format.GeoJSON} -> >> >> { format: OpenLayers.Format.GeoJSON, >> >> projection: new OpenLayers.Projection("EPSG:4326") >> >> } >> >> >> >> Regards, >> >> -- >> >> Christopher Schmidt >> >> MetaCarta >> >> >> > >> > >> > http://mybiosis.info >> > >> >
_______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users