Email updated
[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.Navigation(),
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                     {wrapDateLine: true} );
72             map.addLayer(layer);
73             //map.addLayer(new OpenLayers.Layer.OSM.Mapnik("Mapnik"));
74             //map.addLayer(new OpenLayers.Layer.Text("IP Locations", {
75             //    location: map_file, projection: new OpenLayers.Projection("EPSG:4326")} ) );
76             //
77             //map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
78
79             var geojson_format = new OpenLayers.Format.GeoJSON();
80             var vector_layer = new OpenLayers.Layer.Vector("IP Endpoints");
81             map.addLayer(vector_layer);
82             vector_layer.addFeatures(geojson_format.read(endpoints));
83
84             if (endpoints.features.length < 1) {
85                 document.getElementById("statusmsg").innerHTML = "No endpoints to map";
86             } else {
87                 map.zoomToExtent(vector_layer.getDataExtent());
88             }
89
90             selectControl = new OpenLayers.Control.SelectFeature(vector_layer);
91             map.addControl(selectControl);
92             selectControl.activate();
93
94             vector_layer.events.on({
95                 'featureselected': EndpointSelected,
96                 'featureunselected': EndpointUnselected
97             });
98         }
99         // -->
100     </script>
101   </head>
102   <body onload="init()">
103     <div id="statusmsg" style="float: right; z-index: 9999;"></div>
104     <div id="map" style="z-index: 0;"></div>
105   </body>
106 </html>