<div dir="ltr">Thank you very much for your answer. I have therefore started to investigate the possiblity to use the GeoJSON format, and now I am trying to train with this format with this example but it doesn't work<div><br></div><div><div> <script type="text/javascript"></div><div><br></div><div> var map = new OpenLayers.Map("my_map");<br></div><div> </div><div> var layer = new OpenLayers.Layer.OSM("OpenStreetMap");</div><div> map.addLayer(layer);</div><div> </div><div> map.addControl(new OpenLayers.Control.LayerSwitcher());</div><div> map.setCenter(new OpenLayers.LonLat(0,0), 2);</div><div> </div><div> var citiesLayer = new OpenLayers.Layer.Vector("World Cities (GeoJSON)", <br></div><div> { protocol: new OpenLayers.Protocol.HTTP({</div><div> url: "<a href="http://localhost/openlayers/world_cities.json">http://localhost/openlayers/world_cities.json</a>",</div><div> format: new OpenLayers.Format.GeoJSON()</div><div> }),</div><div> strategies: [</div><div> new OpenLayers.Strategy.Fixed(), </div><div> new OpenLayers.Strategy.Cluster({distance: 15})</div><div> ]</div><div> });</div><div> map.addLayer(citiesLayer);</div><div></script></div></div><div><br></div><div>In order to make the protocol work I have installed nginx on my laptop and the url correctly points to the file world_cities.json in my browser. Anyway this example doesn't work, any idea why?</div><div><br></div><div>Thanks! </div><div>Niccolò</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-19 15:54 GMT+02:00 Mark Prins <span dir="ltr"><<a href="mailto:mc.prins@gmail.com" target="_blank">mc.prins@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">using plain text or (geo) json is much less error prone than using<br>
GML, and probably gives better performance<br>
<div><div class="h5"><br>
2014-09-19 15:45 GMT+02:00 Niccolò Dal Santo <<a href="mailto:ncl.dalsanto@gmail.com">ncl.dalsanto@gmail.com</a>>:<br>
> Hi there,<br>
><br>
> I am new of Openlayers and I need to show some points that come from a<br>
> database on a map centred in Turin (Italy), with some information related to<br>
> this point (for instance an image). Searching on line I have found that<br>
> Openlayers supports many formats of data like GML, KML, GeoJSON and many<br>
> others. Could you suggest a format useful fror my problem and maybe some<br>
> examples of how to use it?<br>
><br>
> I have tried with this code generating a map of europe, but it doesn't work<br>
><br>
> <html><br>
> <head><br>
> <title>Prova GML</title><br>
> <script src="<a href="http://openlayers.org/api/OpenLayers.js" target="_blank">http://openlayers.org/api/OpenLayers.js</a>"></script><br>
> </head><br>
> <body><br>
> <div id="ch3_gml" style="width: 100%; height: 100%;"></div><br>
><br>
> <script type="text/javascript"><br>
><br>
> // Create the map using the specified DOM element<br>
> var map = new OpenLayers.Map("ch3_gml");<br>
><br>
> var layer = new OpenLayers.Layer.OSM("OpenStreetMap");<br>
> map.addLayer(layer);<br>
><br>
> map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
> map.setCenter(new OpenLayers.LonLat(0,0), 2);<br>
><br>
> map.addLayer(new OpenLayers.Layer.Vector("Europe (GML)", {<br>
> protocol: new OpenLayers.Protocol.HTTP({<br>
> url: "./europe.gml",<br>
> format: new OpenLayers.Format.GML()<br>
> }),<br>
> strategies: [new OpenLayers.Strategy.Fixed()]<br>
> }));<br>
> </script><br>
> </body><br>
> </html><br>
><br>
> where europe.gml is a gml file in the same folder of this script, but<br>
> nothing happens.<br>
><br>
> Thank you very much for your help!<br>
><br>
> Regards<br>
><br>
> Niccolò<br>
><br>
> --<br>
> Niccolò Dal Santo<br>
> <a href="tel:%2B39%20342%2015%2070%20842" value="+393421570842">+39 342 15 70 842</a><br>
> <a href="mailto:ncl.dalsanto@gmail.com">ncl.dalsanto@gmail.com</a><br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Disclaimer;<br>
This message is just a reflection of what I thought at the time of<br>
sending. The message may contain information that is not intended for<br>
you or that you don't understand.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a></font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Niccolò Dal Santo<div>+39 342 15 70 842</div><div><a href="mailto:ncl.dalsanto@gmail.com" target="_blank">ncl.dalsanto@gmail.com</a></div>
</div>