Projet

Général

Profil

Révision ef05758b

Ajouté par Jocelyn Delande il y a presque 11 ans

whitespaces + moved the loading to the HTML file

Voir les différences:

js/utils_osm.js
1
function draw_map() {
1

  
2
/** Draws the map for the "view this cap" feature
3
 */
4
function draw_cap_map() {
2 5

  
3 6
    var zcontrol;
4 7
    if (typeof zoom_control != 'undefined') {
......
11 14
	    zcontrol = new OpenLayers.Control.Zoom();
12 15
	}
13 16
    } else zcontrol = new OpenLayers.Control.Zoom();
14
    
17

  
15 18
    var map = new OpenLayers.Map({
16 19
	div: "map",
17 20
        zoom: typeof zoom == 'undefined' ? 10:zoom,
......
19 22
		  new OpenLayers.Control.KeyboardDefaults(),
20 23
		  new OpenLayers.Control.Navigation()],
21 24
    });
22
    
25

  
23 26
    if (typeof scale_line != 'undefined' && scale_line == true) {
24 27
	map.addControl(new OpenLayers.Control.ScaleLine({bottomOutUnits: ''}));
25 28
    }
26
    
29

  
27 30
    if (typeof base_layers != 'undefined') {
28 31
	var layers = new OpenLayers.Control.LayerSwitcher();
29 32
	map.addControl(layers);
30 33
	for (var i = 0; i < base_layers.length; i++) {
31 34
	    map.addLayer(base_layers[i]);
32 35
	}
33
	
36

  
34 37
	// gestion du 45° google //
35 38
	function update_tilt() {
36 39
	    for (var i = 0; i < base_layers.length; i++) {
......
44 47
	}
45 48
	document.getElementById("tilt").onchange = update_tilt;
46 49
	// fin de gestion du 45° google //
47
	
50

  
48 51
	// autres tests
49 52
	function show_pos(e) {
50 53
	    alert(formatLonlats(map.getLonLatFromViewPortPx(e.xy)));
......
61 64
	var panel = new OpenLayers.Control.Panel({
62 65
	    div: document.getElementById("panel")
63 66
	});
64
	
67

  
65 68
	function formatLonlats(lonLat) {
66 69
	    lonLat.transform(map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
67 70
            var lat = lonLat.lat;
......
69 72
	    var dist = OpenLayers.Util.distVincenty(lonLat, new OpenLayers.LonLat(ln.lon1, ln.lat1))*1000;
70 73
            return lat.toFixed(5) + ', ' + lon.toFixed(5) + ' à ' + parseInt(dist) + ' mètres';
71 74
	}
72
	
75

  
73 76
	map.addControl (new OpenLayers.Control.MousePosition({
74 77
	    div: document.getElementById("position"),
75 78
	    formatOutput: formatLonlats
......
122 125
	    color:       def_line_style.color? def_line_style.color:'#00F',
123 126
	    length:      def_line_style.length? def_line_style.length:20000,
124 127
	    opacity:     def_line_style.opacity? def_line_style.opacity:1}
125
	
126
	var lineLayer = new OpenLayers.Layer.Vector("ref_lines"); 
127
	map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path));                                     
128

  
129
	var lineLayer = new OpenLayers.Layer.Vector("ref_lines");
130
	map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path));
128 131
	for (var i = 0; i < ref_lines.length; i++) {
129 132
	    var ln = ref_lines[i];
130 133
	    if(isNaN(ln.cap)) {
......
142 145
	    points[1].transform("EPSG:4326", map.getProjectionObject());
143 146
	    var line = new OpenLayers.Geometry.LineString(points);
144 147

  
145
	    var style = { 
146
		strokeColor:   ln.color? ln.color:def_ln.color, 
148
	    var style = {
149
		strokeColor:   ln.color? ln.color:def_ln.color,
147 150
		strokeWidth:   ln.width? ln.width:def_ln.width,
148 151
		strokeOpacity: ln.width? ln.opacity:def_ln.opacity
149 152
	    };
......
151 154
	    var lineFeature = new OpenLayers.Feature.Vector(line, null, style);
152 155
	    lineLayer.addFeatures([lineFeature]);
153 156
	}
154
	map.addLayer(lineLayer);                    
157
	map.addLayer(lineLayer);
155 158
    }
156 159

  
157 160
    if (typeof ref_point != 'undefined') ref_points = [ref_point];
158 161
    if (typeof ref_points != 'undefined') {
159
	refpts_layer = new OpenLayers.Layer.Vector("ref_points", {projection: "EPSG:4326"}); 
162
	refpts_layer = new OpenLayers.Layer.Vector("ref_points", {projection: "EPSG:4326"});
160 163
	var selectMarkerControl = new OpenLayers.Control.SelectFeature(refpts_layer, {
161 164
	    onSelect: function(feature) {
162 165
		var le_popup = new OpenLayers.Popup.FramedCloud("Popup",
......
179 182
	    toggle: true,
180 183
	});
181 184
	map.addControl(selectMarkerControl);
182
	
185

  
183 186
	selectMarkerControl.activate();
184 187
	map.addLayer(refpts_layer);
185
	
188

  
186 189

  
187 190
	if (typeof def_points_style == 'undefined') def_points_style = {};
188 191
	var def_pt = {
......
193 196
	    icon_shiftX: def_points_style.icon_shiftX ? def_points_style.icon_shiftX:0,
194 197
	    icon_shiftY: def_points_style.icon_shiftY ? def_points_style.icon_shiftY:0,
195 198
	    opacity:     def_points_style.opacity ? def_points_style.opacity:1}
196
	
199

  
197 200
	for (var i = 0; i < ref_points.length; i++) {
198 201
	    var pt = ref_points[i];
199 202
            var ptGeo = new OpenLayers.Geometry.Point(pt.lon, pt.lat);
......
223 226
	});
224 227
    }
225 228
}
226

  
227
if (typeof addLoadEvent == 'function') addLoadEvent(draw_map);
228
else window.onload = draw_map;
show_capline.php
80 80
					       )];
81 81

  
82 82
</script>
83
<script src="js/utils_osm.js"></script>
83
<script src="js/utils_osm.js">
84
</script>
84 85
EOS;
85 86
}
86 87
?>
88
<script>
89
if (typeof addLoadEvent == 'function') addLoadEvent(draw_cap_map);
90
else window.onload = draw_cap_map;
91
</script>
87 92
</head>
88 93
<body>
89 94
<?php

Formats disponibles : Unified diff