This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopenlayers-bug-demo.html
50 lines (48 loc) · 1.7 KB
/
openlayers-bug-demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<title>Dateline in viewport bug case</title>
</head>
<body>
<div id="map_canvas"
style="width: 800px; height: 600px; border: 1px solid grey;">
</div>
<script src="http://www.openlayers.org/dev/OpenLayers.js"></script>
<script>
var wgs84 = new OpenLayers.Projection("EPSG:4326");
var smp = new OpenLayers.Projection("EPSG:900913");
var osm = new OpenLayers.Layer.OSM("Mapnik");
var map = new OpenLayers.Map("map_canvas", {
displayProjection: wgs84,
projection: smp,
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.KeyboardDefaults(),
]
});
map.addLayer(osm);
map.zoomToMaxExtent();
map.setCenter((new OpenLayers.LonLat(168.0, -41.0)).transform(wgs84, smp), 6);
var vector_layer = new OpenLayers.Layer.Vector('Vector features');
var lon1 = 170.0,
lon2 = 175.0,
lat1 = -45.0,
lat2 = -38.0;
var boundsWGS84 = [
new OpenLayers.Geometry.Point(lon1, lat1),
new OpenLayers.Geometry.Point(lon1, lat2),
new OpenLayers.Geometry.Point(lon2, lat2),
new OpenLayers.Geometry.Point(lon2, lat1)
];
var sample_geom = new OpenLayers.Geometry.Polygon([
new OpenLayers.Geometry.LinearRing(boundsWGS84)
]).transform(wgs84, smp);
vector_layer.addFeatures([new OpenLayers.Feature.Vector(sample_geom)]);
map.addLayer(vector_layer);
</script>
</body>
</html>