Commits

sirex  committed e6b5155 Draft

Template changes.

  • Participants
  • Parent commits ff568b6

Comments (0)

Files changed (1)

File src/trolis/templates/index.jinja

   </head>
   <body>
     <div class="container">
-      <div id="map" style="width:100%; height:400px;"></div>
+      <div id="map" style="width:100%; height:600px;"></div>
     </div>
     <script src="jquery.min.js"></script>
     <script src="twbs/dist/js/bootstrap.min.js"></script>
     <script src="openlayers/OpenLayers.js"></script>
     <script type="text/javascript">
     $(function () {
-        var map, layer;
+        var map, osmLayer, kmlLayer;
+
+        var projection = new OpenLayers.Projection('EPSG:4326');
+
         map = new OpenLayers.Map('map');
-        layer = new OpenLayers.Layer.OSM('Trolis');
-        map.addLayer(layer);
 
-        map.addLayer(
-          new OpenLayers.Layer.Vector('KML', {
-              strategies: [new OpenLayers.Strategy.Fixed()],
-              protocol: new OpenLayers.Protocol.HTTP({
-                  url: '/tmp/lines.kml',
-                  format: new OpenLayers.Format.KML({
-                      extractStyles: true, 
-                      extractAttributes: true,
-                      maxDepth: 2
-                  })
-              })
-          })
-        );
+        osmLayer = new OpenLayers.Layer.OSM('Trolis');
+        map.addLayer(osmLayer);
 
+
+        var myStyles = new OpenLayers.StyleMap({
+            'default': new OpenLayers.Style({
+                strokeWidth:1,
+                fillColor: "${getColor}",
+                pointRadius: 5,
+            },
+            {
+                context: {
+                    getColor : function (feature) {
+                        return feature.attributes.color.value;
+                    }
+                }
+            })
+        });
+
+
+        kmlLayer = new OpenLayers.Layer.Vector("KML", {
+            styleMap: myStyles,
+            projection: projection,
+            strategies: [new OpenLayers.Strategy.Fixed()],
+            protocol: new OpenLayers.Protocol.HTTP({
+                //url: 'openlayers/examples/kml/lines.kml',
+                url: 'lines.kml',
+                format: new OpenLayers.Format.KML({
+                    //internalProjection: projection,
+                    //externalProjection: map.getProjectionObject(),
+                    extractStyles: false,
+                    extractAttributes: true,
+                    maxDepth: 8
+                })
+            })
+        });
+        map.addLayer(kmlLayer);
+
+        //map.zoomToMaxExtent();
+        //map.zoomToExtent(kmlLayer.getDataExtent());
+
+        //map.zoomToMaxExtent();
         map.setCenter(
             new OpenLayers.LonLat(25.241, 54.696).transform(
                 new OpenLayers.Projection('EPSG:4326'),
                 map.getProjectionObject()
             ), 13
         );
+
+        // var map = new OpenLayers.Map({
+        // div: "map",
+        // layers: [
+        //     new OpenLayers.Layer.WMS(
+        //         "WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
+        //         {layers: "basic"}
+        //     ),
+        //     new OpenLayers.Layer.Vector("KML", {
+        //         strategies: [new OpenLayers.Strategy.Fixed()],
+        //         protocol: new OpenLayers.Protocol.HTTP({
+        //             url: "lines.kml",
+        //             format: new OpenLayers.Format.KML({
+        //                 internalProjection: projection,
+        //                 extractStyles: true, 
+        //                 extractAttributes: true,
+        //                 maxDepth: 2
+        //             })
+        //         })
+        //     })
+        // ]
+        // });
+        // //map.zoomToMaxExtent();
+        // map.setCenter(
+        //     new OpenLayers.LonLat(25.241, 54.696).transform(
+        //         projection, map.getProjectionObject()
+        //     ), 13
+        // );
     });
     </script>
   </body>