[OpenLayers-Users] Newby: Display geoJSON Layer

Helmut Seidel M.A. info at knowhow-la.de
Tue Jun 4 04:51:43 PDT 2013


Hello everybody,

 

I’m absolutely new to OpenLayers – For a start I wanted to check out the
possibilities of OpenLayers and display a geoJSON-Layer which should act as
the base layer. The layer uses the projection ESPSG 31468 / DHDN /
Gauss-Krüger 4.

 

To say it in plain words I’m not too successfull in this, as nothing is
displayed.

 

I tried the following code which I copied from various sources:

 

<html>

                <head>

                               <script src="Lib/OpenLayers.js"></script>

                               <script type="text/javascript">

                               var map;

                               function init(){

                                               var lon = 4596651.93;

                                               var lat = 5355977.11;

 

                                               map = new
OpenLayers.Map('map', {

                                                               projection:
"EPSG:31468"

                                               });

 

                                               var kmlLayer = new
OpenLayers.Layer.Vector("GeoJSON", {

                                                               isBaseLayer:
true,

                                                               strategies:
[new OpenLayers.Strategy.Fixed()],

                                                               protocol: new
OpenLayers.Protocol.HTTP({

 
url: "flurstuecke.json",

 
format: new OpenLayers.Format.GeoJSON()

                                                               })

                                               });

                                               map.addLayers([kmlLayer]);

                                               map.addControl(new
OpenLayers.Control.MousePosition());

                                               map.setCenter(new
OpenLayers.LonLat(lon, lat), 10);

 

                               }

                               </script>

                </head>

                <body onload="init()">

                               <div id="map" style="width:300px;
height:300px;

                                               border: 1px solid
black;"></div>

                </body>

</html>

 

Can anybody tell me whats wrong with it?

 

By the way, how is it possible to retrive the extends of a geoJSON file?

 

Thank you all and regards

 

 

---

KnowHow - Helmut Seidel M.A.

Softwareentwicklung & Coaching

 

Gabelsbergerstraße 17 B

84034 Landshut

Telefon: 0871 9665230

Internet: www.knowhow-la.de

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130604/ff808db1/attachment-0001.html>


More information about the Users mailing list