Instead of loading our coordinates from a separate text file via
[metze/wireshark/wip.git] / ipmap.html
1 <?xml version="1.0" encoding="UTF-8"?>
2 <html xmlns="http://www.w3.org/1999/xhtml">
3   <head>
4     <title>Wireshark: IP Location Map</title>
5     <style type="text/css">
6     body {
7       font-family: Arial, Helvetica, sans-serif; font-size: 13px;
8       line-height: 17px;
9     }
10     </style>
11     <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
12     <script type="text/javascript" src="http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
13
14     <script type="text/javascript">
15         <!--
16         var map, layer;
17         var selectControl, selectedFeature;
18
19         function onPopupClose(event) {
20             selectControl.unselect(this.feature);
21         }
22
23         function EndpointSelected(event) {
24             var feature = event.feature;
25             popup = new OpenLayers.Popup.FramedCloud("endpoint",
26                 feature.geometry.getBounds().getCenterLonLat(),
27                 new OpenLayers.Size(25,25),
28                 "<h3>"+ feature.attributes.title + "</h3>" +
29                 feature.attributes.description,
30                 null, true, onPopupClose);
31             feature.popup = popup;
32             popup.feature = feature;
33             map.addPopup(popup);
34         }
35
36         function EndpointUnselected(event) {
37             var feature = event.feature;
38             if (feature.popup) {
39                 popup.feature = null;
40                 map.removePopup(feature.popup);
41                 feature.popup.destroy();
42                 feature.popup = null;
43             }
44         }
45
46         function init() {
47             var endpoints = {
48                 "type": "FeatureCollection",
49                 "features": [ // Start endpoint list - MUST match hostlist_table.c
50                 ]
51             };
52             map = new OpenLayers.Map('map', {
53                 controls: [
54                     new OpenLayers.Control.PanZoomBar(),
55                     new OpenLayers.Control.ZoomBox(),
56                     new OpenLayers.Control.ScaleLine(),
57                     new OpenLayers.Control.MousePosition(),
58                     new OpenLayers.Control.MouseDefaults(),
59                     new OpenLayers.Control.Attribution()
60                     ],
61                 //projection: new OpenLayers.Projection("EPSG:900913"),
62                 //displayProjection: new OpenLayers.Projection("EPSG:4326"),
63                 //maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34, 20037508.34, 20037508.34),
64                 //numZoomLevels: 18,
65                 //maxResolution: 156543,
66                 //units: "m"
67             });
68             layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
69                     "http://vmap0.tiles.osgeo.org/wms/vmap0",
70                     {layers: 'basic'} );
71             map.addLayer(layer);
72             //map.addLayer(new OpenLayers.Layer.OSM.Mapnik("Mapnik"));
73             //map.addLayer(new OpenLayers.Layer.Text("IP Locations", {
74             //    location: map_file, projection: new OpenLayers.Projection("EPSG:4326")} ) );
75             //
76             //map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
77
78             var geojson_format = new OpenLayers.Format.GeoJSON();
79             var vector_layer = new OpenLayers.Layer.Vector("IP Endpoints");
80             map.addLayer(vector_layer);
81             vector_layer.addFeatures(geojson_format.read(endpoints));
82
83             if (endpoints.features.length < 1) {
84                 document.getElementById("statusmsg").innerHTML = "No endpoints to map";
85             } else {
86                 map.zoomToExtent(vector_layer.getDataExtent());
87             }
88
89             selectControl = new OpenLayers.Control.SelectFeature(vector_layer);
90             map.addControl(selectControl);
91             selectControl.activate();
92
93             vector_layer.events.on({
94                 'featureselected': EndpointSelected,
95                 'featureunselected': EndpointUnselected
96             });
97         }
98         // -->
99     </script>
100   </head>
101   <body onload="init()">
102     <div id="statusmsg" style="float: right; z-index: 9999;"></div>
103     <div id="map" style="z-index: 0;"></div>
104   </body>
105 </html>