Hi, your map is in projection EPSG:900913 (OSM). Are your data also in this projection or perhaps in EPSG:4326 (lonlat)?
If so, it could be that your data are shown (at x=0,y=0), but you only can't see them. Regards, Arnd _____ Von: openlayers-users-boun...@lists.osgeo.org [mailto:openlayers-users-boun...@lists.osgeo.org] Im Auftrag von Niccolò Dal Santo Gesendet: Freitag, 19. September 2014 23:11 An: Mark Prins Cc: openlayers-users Betreff: Re: [OpenLayers-Users] Showing points from a database 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 <script type="text/javascript"> var map = new OpenLayers.Map("my_map"); var layer = new OpenLayers.Layer.OSM("OpenStreetMap"); map.addLayer(layer); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(0,0), 2); var citiesLayer = new OpenLayers.Layer.Vector("World Cities (GeoJSON)", { protocol: new OpenLayers.Protocol.HTTP({ url: "http://localhost/openlayers/world_cities.json", format: new OpenLayers.Format.GeoJSON() }), strategies: [ new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster({distance: 15}) ] }); map.addLayer(citiesLayer); </script> 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? Thanks! Niccolò 2014-09-19 15:54 GMT+02:00 Mark Prins <mc.pr...@gmail.com>: using plain text or (geo) json is much less error prone than using GML, and probably gives better performance 2014-09-19 15:45 GMT+02:00 Niccolò Dal Santo <ncl.dalsa...@gmail.com>: > Hi there, > > I am new of Openlayers and I need to show some points that come from a > database on a map centred in Turin (Italy), with some information related to > this point (for instance an image). Searching on line I have found that > Openlayers supports many formats of data like GML, KML, GeoJSON and many > others. Could you suggest a format useful fror my problem and maybe some > examples of how to use it? > > I have tried with this code generating a map of europe, but it doesn't work > > <html> > <head> > <title>Prova GML</title> > <script src="http://openlayers.org/api/OpenLayers.js"></script> > </head> > <body> > <div id="ch3_gml" style="width: 100%; height: 100%;"></div> > > <script type="text/javascript"> > > // Create the map using the specified DOM element > var map = new OpenLayers.Map("ch3_gml"); > > var layer = new OpenLayers.Layer.OSM("OpenStreetMap"); > map.addLayer(layer); > > map.addControl(new OpenLayers.Control.LayerSwitcher()); > map.setCenter(new OpenLayers.LonLat(0,0), 2); > > map.addLayer(new OpenLayers.Layer.Vector("Europe (GML)", { > protocol: new OpenLayers.Protocol.HTTP({ > url: "./europe.gml", > format: new OpenLayers.Format.GML() > }), > strategies: [new OpenLayers.Strategy.Fixed()] > })); > </script> > </body> > </html> > > where europe.gml is a gml file in the same folder of this script, but > nothing happens. > > Thank you very much for your help! > > Regards > > Niccolò > > -- > Niccolò Dal Santo > +39 342 15 70 842 <tel:%2B39%20342%2015%2070%20842> > ncl.dalsa...@gmail.com > > _______________________________________________ > Users mailing list > us...@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/openlayers-users -- Disclaimer; This message is just a reflection of what I thought at the time of sending. The message may contain information that is not intended for you or that you don't understand. _______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users -- Niccolò Dal Santo +39 342 15 70 842 ncl.dalsa...@gmail.com --- Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz ist aktiv. http://www.avast.com
_______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users