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