Révision ed5e83c5
Ajouté par Marc Souviron il y a environ 11 ans
js/utils_osm.js | ||
---|---|---|
24 | 24 |
map.addControl(new OpenLayers.Control.ScaleLine({bottomOutUnits: ''})); |
25 | 25 |
} |
26 | 26 |
|
27 |
map.addLayer(new OpenLayers.Layer.OSM()); |
|
27 |
if (typeof base_layers != 'undefined') { |
|
28 |
map.addControl(new OpenLayers.Control.LayerSwitcher()); |
|
29 |
for (var i = 0; i < base_layers.length; i++) { |
|
30 |
map.addLayer(base_layers[i]); |
|
31 |
if (base_layers[i].type == google.maps.MapTypeId.SATELLITE) { |
|
32 |
base_layers[i].mapObject.setTilt(0); |
|
33 |
} |
|
34 |
} |
|
35 |
} else { |
|
36 |
map.addLayer(new OpenLayers.Layer.OSM()); |
|
37 |
} |
|
28 | 38 |
|
29 | 39 |
if (typeof contour != 'undefined') contours = [contour]; |
30 | 40 |
if (typeof contours == 'undefined') contours = new Array; |
... | ... | |
53 | 63 |
map.addLayer(cntr); |
54 | 64 |
} |
55 | 65 |
|
66 |
if (typeof ref_line != 'undefined') ref_lines = [ref_line]; |
|
67 |
if (typeof ref_lines != 'undefined') { |
|
68 |
if (typeof def_line_style == 'undefined') def_line_style = {}; |
|
69 |
var def_ln = { |
|
70 |
width: def_line_style.width? def_line_style.width:2, |
|
71 |
color: def_line_style.color? def_line_style.color:'#00F', |
|
72 |
length: def_line_style.length? def_line_style.length:20000, |
|
73 |
opacity: def_line_style.opacity? def_line_style.opacity:1} |
|
74 |
|
|
75 |
var lineLayer = new OpenLayers.Layer.Vector("ref_lines"); |
|
76 |
map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path)); |
|
77 |
for (var i = 0; i < ref_lines.length; i++) { |
|
78 |
var ln = ref_lines[i]; |
|
79 |
if(isNaN(ln.cap)) { |
|
80 |
var pt = {lon: ln.lon2, lat: ln.lat2}; |
|
81 |
} else { |
|
82 |
var LonLat = new OpenLayers.LonLat(ln.lon1, ln.lat1); |
|
83 |
var dist = ln.length? ln.length:def_ln.length; |
|
84 |
var pt = OpenLayers.Util.destinationVincenty(LonLat, ln.cap, dist); |
|
85 |
} |
|
86 |
var points = new Array( |
|
87 |
new OpenLayers.Geometry.Point(ln.lon1, ln.lat1), |
|
88 |
new OpenLayers.Geometry.Point(pt.lon, pt.lat) |
|
89 |
); |
|
90 |
points[0].transform("EPSG:4326", map.getProjectionObject()); |
|
91 |
points[1].transform("EPSG:4326", map.getProjectionObject()); |
|
92 |
var line = new OpenLayers.Geometry.LineString(points); |
|
93 |
|
|
94 |
var style = { |
|
95 |
strokeColor: ln.color? ln.color:def_ln.color, |
|
96 |
strokeWidth: ln.width? ln.width:def_ln.width, |
|
97 |
strokeOpacity: ln.width? ln.opacity:def_ln.opacity |
|
98 |
}; |
|
99 |
|
|
100 |
var lineFeature = new OpenLayers.Feature.Vector(line, null, style); |
|
101 |
lineLayer.addFeatures([lineFeature]); |
|
102 |
} |
|
103 |
map.addLayer(lineLayer); |
|
104 |
} |
|
105 |
|
|
56 | 106 |
if (typeof ref_point != 'undefined') ref_points = [ref_point]; |
57 | 107 |
if (typeof ref_points != 'undefined') { |
58 | 108 |
refpts_layer = new OpenLayers.Layer.Vector("ref_points", {projection: "EPSG:4326"}); |
... | ... | |
114 | 164 |
} |
115 | 165 |
if (typeof zoom == 'undefined') map.zoomToExtent(refpts_layer.getDataExtent()); |
116 | 166 |
} |
117 |
|
|
118 |
if (typeof ref_line != 'undefined') ref_lines = [ref_line]; |
|
119 |
if (typeof ref_lines != 'undefined') { |
|
120 |
if (typeof def_line_style == 'undefined') def_line_style = {}; |
|
121 |
var def_ln = { |
|
122 |
width: def_line_style.width? def_line_style.width:2, |
|
123 |
color: def_line_style.color? def_line_style.color:'#00F', |
|
124 |
length: def_line_style.length? def_line_style.length:20000, |
|
125 |
opacity: def_line_style.opacity? def_line_style.opacity:1} |
|
126 |
|
|
127 |
var lineLayer = new OpenLayers.Layer.Vector("ref_lines"); |
|
128 |
map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path)); |
|
129 |
for (var i = 0; i < ref_lines.length; i++) { |
|
130 |
var ln = ref_lines[i]; |
|
131 |
if(isNaN(ln.cap)) { |
|
132 |
var pt = {lon: ln.lon2, lat: ln.lat2}; |
|
133 |
} else { |
|
134 |
var LonLat = new OpenLayers.LonLat(ln.lon1, ln.lat1); |
|
135 |
var dist = ln.length? ln.length:def_ln.length; |
|
136 |
var pt = OpenLayers.Util.destinationVincenty(LonLat, ln.cap, dist); |
|
137 |
} |
|
138 |
var points = new Array( |
|
139 |
new OpenLayers.Geometry.Point(ln.lon1, ln.lat1), |
|
140 |
new OpenLayers.Geometry.Point(pt.lon, pt.lat) |
|
141 |
); |
|
142 |
points[0].transform("EPSG:4326", map.getProjectionObject()); |
|
143 |
points[1].transform("EPSG:4326", map.getProjectionObject()); |
|
144 |
var line = new OpenLayers.Geometry.LineString(points); |
|
145 |
|
|
146 |
var style = { |
|
147 |
strokeColor: ln.color? ln.color:def_ln.color, |
|
148 |
strokeWidth: ln.width? ln.width:def_ln.width, |
|
149 |
strokeOpacity: ln.width? ln.opacity:def_ln.opacity |
|
150 |
}; |
|
151 |
|
|
152 |
var lineFeature = new OpenLayers.Feature.Vector(line, null, style); |
|
153 |
lineLayer.addFeatures([lineFeature]); |
|
154 |
} |
|
155 |
map.addLayer(lineLayer); |
|
156 |
} |
|
157 | 167 |
if (typeof get_lon_lat != 'undefined' && get_lon_lat) { |
158 | 168 |
map.events.register("click", map, function(e) { |
159 | 169 |
var position = map.getLonLatFromViewPortPx(e.xy); |
160 | 170 |
position.transform(map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326")); |
161 |
alert(position.lon.toFixed(3) + ', ' + position.lat.toFixed(3));
|
|
171 |
alert(position.lat.toFixed(5) + ', ' + position.lon.toFixed(5));
|
|
162 | 172 |
}); |
163 | 173 |
} |
164 | 174 |
} |
Formats disponibles : Unified diff
Amélioration du système de navigation assisté par OSM ou google
Correction d'un bug de non-linéarité sur les panoramas rebouclés (360°)
simplification du style