[OpenLayers-Users] How do I make the map static?

Marco Baumgärtner kalleernst at googlemail.com
Mon Jul 30 01:40:23 PDT 2012


Using a smartphone(android) I cannot scroll down on the page containing 
an almost full-screen map as moving the finger over the map makes the 
map pan instead. Which is nice in general but not in this case. How do I 
make the map static?

This is my code:

> <div style="width: 100%; height: 100%;" id="mapdiv">
>
> </div>
>
> <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
>
> <?php
>
>   $bildn = "image.png";
>
>   $gr = getimagesize($bildn); ?>
>
> <script>
>
>   OpenLayers.Lang.setCode('de');
>
>   map = new OpenLayers.Map("mapdiv");
>
>   map.addLayer(new OpenLayers.Layer.OSM());
>
>   projectTo = map.getProjectionObject();
>
>   epsg4326 = new OpenLayers.Projection("EPSG:4326")
>
>   var lonLat = new OpenLayers.LonLat( <?php echo $_GET['lon']; ?> , 
> <?php echo $_GET['lat']; ?> ).transform(epsg4326, projectTo);
>
>   var zoom = <?php echo $radius; ?> ;
>
>   map.setCenter(lonLat, zoom);
>
>   var vectorLayer = new OpenLayers.Layer.Vector("Overlay");
>
>   var feature = new OpenLayers.Feature.Vector(
>
>   new OpenLayers.Geometry.Point( <?php echo $_GET['lon']; ?> , <?php 
> echo $_GET['lat']; ?> ).transform(epsg4326, projectTo),
>
>   {
>
>       description: 'Here'
>
>   },
>
>   {
>
>       externalGraphic: '<?php echo $bildn; ?>',
>
>       graphicHeight: <?php echo $gr[1]; ?> , graphicWidth: <?php echo 
> $gr[0]; ?> , graphicXOffset: <?php echo - $gr[0] / 2; ?> , 
> graphicYOffset: <?php echo - $gr[1]; ?>
>
>   });
>
>   vectorLayer.addFeatures(feature);
>
>   map.addLayer(vectorLayer);
>
>   //Add a selector control to the vectorLayer with popup functions
>
>   var controls = {
>
>       selector: new OpenLayers.Control.SelectFeature(vectorLayer,
>
>       {
>
>           onSelect: createPopup,
>
>           onUnselect: destroyPopup
>
>       })
>
>   };
>
>
>
>   function createPopup(feature)
>
>   {
>
>       feature.popup = new OpenLayers.Popup.FramedCloud("pop",
>
>       feature.geometry.getBounds().getCenterLonLat(),
>
>       null, '<div class="markerContent">' + 
> feature.attributes.description + '</div>',
>
>       null,
>
>       true,
>
>
>
>       function ()
>
>       {
>
>           controls['selector'].unselectAll();
>
>       });
>
>       //feature.popup.closeOnMove = true;
>
>       map.addPopup(feature.popup);
>
>   }
>
>
>
>   function destroyPopup(feature)
>
>   {
>
>       feature.popup.destroy();
>
>       feature.popup = null;
>
>   }
>
>   map.addControl(controls['selector']);
>
>   controls['selector'].activate();
>
>   </script>



More information about the Users mailing list