Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make openlayers map

  • Loading branch information...
commit 29f883ddc5c28e7ee5924c967834abc9c60c26a2 1 parent ed917b1
@exonian exonian authored
View
6 weather/static/css/weather.css
@@ -9,7 +9,7 @@ header, footer {
text-align: center;
}
-div.full-map {
- width 80%;
-
+#map {
+ width: 100%;
+ height: 400px;
}
View
2,885 weather/static/js/OpenLayers.js
2,885 additions, 0 deletions not shown
View
57 weather/templates/floods/base.html
@@ -1,25 +1,6 @@
<html>
<head>
<title></title>
- {% block scripts %}
- <script src="{{ STATIC_URL }}js/openlayers/lib/OpenLayers.js" type="text/javascript"></script>
- <!-- <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script> -->
- <script defer="defer" type="text/javascript">
- "use strict"
- var map, layer;
- map = new OpenLayers.Map('map');
- layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
- map.addLayer(layer);
- map.setCenter(
- new OpenLayers.LonLat(-71.147, 42.472).transform(
- new OpenLayers.Projection("EPSG:4326"),
- map.getProjectionObject()
- ), 12
- );
- </script>
- {% endblock scripts %}
- {% block extrascripts %}
- {% endblock extrascripts %}
{% block styles %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/weather.css" />
{% endblock styles %}
@@ -34,6 +15,44 @@
{% block footer %}
<footer>Created at RHoK</footer>
{% endblock footer %}
+ {% block scripts %}
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="{{ STATIC_URL }}js/openlayers/OpenLayers.js" type="text/javascript"></script>
+ <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
+ <script type="text/javascript">
+ var map = new OpenLayers.Map('map', {
+ controls : [
+ new OpenLayers.Control.LayerSwitcher(),
+ new OpenLayers.Control.PanZoom(),
+ new OpenLayers.Control.ScaleLine(),
+ new OpenLayers.Control.ArgParser(),
+ new OpenLayers.Control.Attribution(),
+ new OpenLayers.Control.Permalink()
+ ]
+ });
+
+ var proj = new OpenLayers.Projection("EPSG:4326");
+ var gphy = new OpenLayers.Layer.Google(
+ "Google Physical",
+ {type: google.maps.MapTypeId.TERRAIN, minZoomLevel: 5, maxZoomLevel: 15 }
+ );
+ var ghyb = new OpenLayers.Layer.Google(
+ "Google Hybrid",
+ {type: google.maps.MapTypeId.HYBRID, minZoomLevel: 5, maxZoomLevel: 19 }
+ );
+ var gsat = new OpenLayers.Layer.Google(
+ "Google Satellite",
+ {type: google.maps.MapTypeId.SATELLITE, minZoomLevel: 5, maxZoomLevel: 19 }
+ );
+
+ map.addLayers([gphy, gsat, ghyb]);
+ var lonlat = new OpenLayers.LonLat(10.2, 48.9);
+ lonlat = lonlat.transform(proj, map.getProjection());
+ map.setCenter(lonlat, 5);
+ </script>
+ {% endblock scripts %}
+ {% block extrascripts %}
+ {% endblock extrascripts %}
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.