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

Andreas Hocevar ahocevar at opengeo.org
Wed Aug 1 04:27:33 PDT 2012


Hi,

just change the line where you create the map to

map = new OpenLayers.Map("mapdiv", {controls: [new
OpenLayers.Control.Attribution()]});

By doing so, your map will be created without navigation controls.

Andreas.

On Tue, Jul 31, 2012 at 9:07 AM, Marco Baumgärtner
<kalleernst at googlemail.com> wrote:
> 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>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list