Source

pyqtwidgets / qtwidgets / olmapwidget / debug.html

Full commit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <head>
    <title></title>
    <link rel="stylesheet" href="file:///home/henning/src/glider/glider_dev/src/qtwidgets/qtwidgets/olmapwidget/static/openlayers/theme/default/style.css" type="text/css">
    <script src="file:///home/henning/src/glider/glider_dev/src/qtwidgets/qtwidgets/olmapwidget/static/openlayers/OpenLayers.js"></script>
    <script src="file:///home/henning/src/glider/glider_dev/src/qtwidgets/qtwidgets/olmapwidget/static/jquery.js"></script>
    <!--    
    -->
    <script src="http://maps.google.com/maps/api/js?v=3.7&sensor=false"></script>
    <!-- 
    -->

    
    <style type="text/css">
        html, body, div {
         margin: 0;
         padding: 0;
        }
        #map {
          height: 480px;
          width: 640px;
        }
    </style>
    
    <script>
  
// HotPath http://trac.osgeo.org/openlayers/wiki/Release/2.11/GoogleMaps37
if(1) OpenLayers.Layer.Google.v3.repositionMapElements = function() {
    // This is the first time any Google layer in this mapObject has been
    // made visible.  The mapObject needs to know the container size.
    google.maps.event.trigger(this.mapObject, "resize");
    
    var div = this.mapObject.getDiv().firstChild;
    if (!div || div.childNodes.length < 3) {
        this.repositionTimer = window.setTimeout(
            OpenLayers.Function.bind(this.repositionMapElements, this),
            250
        );
        return false;
    }

    var cache = OpenLayers.Layer.Google.cache[this.map.id];
    var container = this.map.viewPortDiv;
    
    // move the ToS and branding stuff up to the container div
    // depends on value of zIndex, which is not robust
    for (var i=div.children.length-1; i>=0; --i) {
        if (div.children[i].style.zIndex == 1000001) {
            var termsOfUse = div.children[i];
            container.appendChild(termsOfUse);
            termsOfUse.style.zIndex = "1100";
            termsOfUse.style.bottom = "";
            termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
            termsOfUse.style.display = "";
            cache.termsOfUse = termsOfUse;
        }
        if (div.children[i].style.zIndex == 1000000) {
            var poweredBy = div.children[i];
            container.appendChild(poweredBy);
            poweredBy.style.zIndex = "1100";
            poweredBy.style.bottom = "";
            poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
            poweredBy.style.display = "";
            cache.poweredBy = poweredBy;
        }
        if (div.children[i].style.zIndex == 10000002) {
            container.appendChild(div.children[i]);
        }
    }

    this.setGMapVisibility(this.visibility);
};
    
     $(document).ready(function() {   
     
        var lon = 8.2;
        var lat = 53.166;
        var zoom = 4;
        var map, layer, markers, switcher, controls, options;
     
        switcher = new OpenLayers.Control.LayerSwitcher({'ascending':false});
        controls = [
          new OpenLayers.Control.NavToolbar(),
          new OpenLayers.Control.Navigation(),
          //new OpenLayers.Control.PanZoomBar(),
          new OpenLayers.Control.PanZoom(),
          
          switcher,
          new OpenLayers.Control.MousePosition(),
          //new OpenLayers.Control.OverviewMap(),
          //new OpenLayers.Control.ScaleBar(),               
          new OpenLayers.Control.KeyboardDefaults()
          ];
        
        options = {
          controls: controls,
          displayProjection: new OpenLayers.Projection("EPSG:4326"),  
          projection: new OpenLayers.Projection("EPSG:900913"),
          units: "m",
          maxResolution: 156543.0339,
          maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
        };
        

        map = new OpenLayers.Map('map', options);
        window.map = map;
        
        map.addLayer(new OpenLayers.Layer.OSM());                                             

        var point = new OpenLayers.LonLat(lon, lat);
        var center = point.clone().transform(
          new OpenLayers.Projection("EPSG:4326"),   
          map.getProjectionObject()        
        );
        map.setCenter(center, zoom);

        var markers = new OpenLayers.Layer.Markers( "Markers", {displayInLayerSwitcher: false} );
        window.markers = markers;
        //var marker = new OpenLayers.Marker(point) ;        
        //markers.addMarker(marker);
        map.addLayer(markers);


        map.events.register("click", map , function(e){
             //var opx = map.getLayerPxFromViewPortPx(e.xy) ;
             //marker.map = map ;
             //marker.moveTo(opx);   
             var lonlat = map.getLonLatFromViewPortPx(e.xy);
             var pos = lonlat.clone();
             var newpos = pos.transform(                              
               map.getProjectionObject(),
               new OpenLayers.Projection("EPSG:4326")
                //new OpenLayers.Projection("EPSG:90913")
             );
             window.python.on_mouse_clicked(e.x ,e.y, newpos.lat, newpos.lon);
     
        });
 

        $(window).resize(function() {
          $("#map").width($(window).innerWidth()-4);
          $("#map").height($(window).innerHeight()-4);
        });
        
        $(window).trigger("resize");
        
        window.python.on_ready();
       
     });
    </script>
  </head>

  <body>
    <div id="map"></div>
  </body>
</html>