Skip to main content
added 1671 characters in body
Source Link
Blake Loizides
  • 617
  • 4
  • 16
  • 25
 var map, layer;

        function init(){
       <script src='http    
        layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://mapsvmap0.googletiles.comosgeo.org/maps?file=api&amp;v=2&amp;key=ABQIAAAAl9RMqSzhPUXAfeBCXOussRTQDbvAygy0cfGJr8dEMAYKf3RWNBQqP9mjKIsqTfmAlz5LOJ3Xpy5s4w'><wms/script>
vmap0", {layers: <script'basic'} type="text/javascript">);
        
  // Add Styles
  var lonmyStyles = 5;new OpenLayers.StyleMap({
        var lat = 40; "default": new OpenLayers.Style({
        var zoom = 5;     fillColor: "#000",
        var map       fillOpacity: 0.3, 
 layer;               strokeColor: "#000",
                strokeOpacity: 0.3,
                strokeWidth: 1,
        function init(){       graphicZIndex: 1
            layer}),
 =           "select": new OpenLayers.Layer.WMSStyle({
 "OpenLayers WMS"              fillColor: "#ccc",
                fillOpacity: 0.6,
   "http             strokeColor://vmap0.tiles.osgeo.org/wms/vmap0" "#ccc", 
 {layers               strokeWidth: 'basic'}1,
 );               label: "Label for Mouseover",
                labelAlign: "cc",
                fontColor: "#333333",
                fontOpacity: 0.9,
                fontFamily: "Arial",
                fontSize: 14,
                graphicZIndex: 2
            })
        });

        vlayer = new OpenLayers.Layer.Vector( "Editable",{
            styleMap: myStyles,
            rendererOptions: {zIndexing: true}
        });
        
        map = new OpenLayers.Map( 'map', {
         
        // Add Openlayers Map Controls 
        controls: 
        
                 [
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.MousePosition(),
                    new OpenLayers.Control.ScaleLine(),
                    new OpenLayers.Control.OverviewMap(),
                    new OpenLayers.Control.EditingToolbar(vlayer) 
                                               
                 ]
     
         });
            
// Make Variables for Google Version 3 
var gphy = new OpenLayers.Layer.Google(
    "Google Physical",
    {type: google.maps.MapTypeId.TERRAIN}
);
var gmap = new OpenLayers.Layer.Google(
        "Google Streets", // the default
    {numZoomLevels: 20}
);
var ghyb = new OpenLayers.Layer.Google(
    "Google Hybrid",
    {type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
);
var gsat = new OpenLayers.Layer.Google(
    "Google Satellite",
    {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
); 

    // Add layerlayers to map
    map.addLayeraddLayers([gphy, gmap, ghyb, gsat]);

            map.addLayers([layer, vlayer]);
    
    // Google.v3 uses EPSG:900913 as projection, so we have to transform our coordinates
    map.setCenter(new OpenLayers.LonLat(lon10.2, lat48.9).transform(
    new OpenLayers.Projection("EPSG:4326"), 
 zoom   map.getProjectionObject();
), 5);

   var panel = new OpenLayers.Control.Panel();
    panel.addControls([
        new OpenLayers.Control.Button({
            displayClass: "helpButton", trigger: function() {alert('help')}, title: 'Help'
        })
    ]);
    </script> map.addControl(panel);
                <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAl9RMqSzhPUXAfeBCXOussRTQDbvAygy0cfGJr8dEMAYKf3RWNBQqP9mjKIsqTfmAlz5LOJ3Xpy5s4w'></script>
  <script type="text/javascript">
        var lon = 5;
        var lat = 40;
        var zoom = 5;
        var map, layer;

        function init(){
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
            
            

            vlayer = new OpenLayers.Layer.Vector( "Editable" );
            map = new OpenLayers.Map( 'map', {
                controls: [
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.EditingToolbar(vlayer)                            
                ]
             });
            
            var gmap = new OpenLayers.Layer.Google(
        "Google Streets", // the default
        {numZoomLevels: 20}
    );
    // Add layer to map
    map.addLayer(gmap);

            map.addLayers([layer, vlayer]);

            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);


           

        }

   
    </script>
 var map, layer;

        function init(){
            
        layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
        
  // Add Styles
  var myStyles = new OpenLayers.StyleMap({
            "default": new OpenLayers.Style({
                fillColor: "#000",
                fillOpacity: 0.3, 
                strokeColor: "#000",
                strokeOpacity: 0.3,
                strokeWidth: 1,
                graphicZIndex: 1
            }),
            "select": new OpenLayers.Style({
                fillColor: "#ccc",
                fillOpacity: 0.6,
                strokeColor: "#ccc", 
                strokeWidth: 1,
                label: "Label for Mouseover",
                labelAlign: "cc",
                fontColor: "#333333",
                fontOpacity: 0.9,
                fontFamily: "Arial",
                fontSize: 14,
                graphicZIndex: 2
            })
        });

        vlayer = new OpenLayers.Layer.Vector( "Editable",{
            styleMap: myStyles,
            rendererOptions: {zIndexing: true}
        });
        
        map = new OpenLayers.Map( 'map', {
         
        // Add Openlayers Map Controls 
        controls: 
        
                 [
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.MousePosition(),
                    new OpenLayers.Control.ScaleLine(),
                    new OpenLayers.Control.OverviewMap(),
                    new OpenLayers.Control.EditingToolbar(vlayer) 
                                               
                 ]    
         });
            
// Make Variables for Google Version 3 
var gphy = new OpenLayers.Layer.Google(
    "Google Physical",
    {type: google.maps.MapTypeId.TERRAIN}
);
var gmap = new OpenLayers.Layer.Google(
    "Google Streets", // the default
    {numZoomLevels: 20}
);
var ghyb = new OpenLayers.Layer.Google(
    "Google Hybrid",
    {type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
);
var gsat = new OpenLayers.Layer.Google(
    "Google Satellite",
    {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
); 

    // Add layers to map
    map.addLayers([gphy, gmap, ghyb, gsat]);

    map.addLayers([layer, vlayer]);
    
    // Google.v3 uses EPSG:900913 as projection, so we have to transform our coordinates
    map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform(
    new OpenLayers.Projection("EPSG:4326"), 
    map.getProjectionObject()
), 5);

   var panel = new OpenLayers.Control.Panel();
    panel.addControls([
        new OpenLayers.Control.Button({
            displayClass: "helpButton", trigger: function() {alert('help')}, title: 'Help'
        })
    ]);
     map.addControl(panel);
Source Link
Blake Loizides
  • 617
  • 4
  • 16
  • 25

How to use Google Default Pan/Zoom controls in openlayers

I am using Google maps version 3 with Openlayers,My question is how do you use the default google control for Panning and Zooming and not the default controls Openlayers panning and zooming(The dark blue controls)

I know that it is controlled by the CSS for Openlayers, But what is the default CSS for the Google Pan/Zoom Controls / Where do I find this CSS for the Google controls in the image below.

Google Default Controls Openlayers Pan/Zoom Control

                <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAl9RMqSzhPUXAfeBCXOussRTQDbvAygy0cfGJr8dEMAYKf3RWNBQqP9mjKIsqTfmAlz5LOJ3Xpy5s4w'></script>
  <script type="text/javascript">
        var lon = 5;
        var lat = 40;
        var zoom = 5;
        var map, layer;

        function init(){
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
            
            

            vlayer = new OpenLayers.Layer.Vector( "Editable" );
            map = new OpenLayers.Map( 'map', {
                controls: [
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.EditingToolbar(vlayer)                            
                ]
            });
            
            var gmap = new OpenLayers.Layer.Google(
        "Google Streets", // the default
        {numZoomLevels: 20}
    );
    // Add layer to map
    map.addLayer(gmap);

            map.addLayers([layer, vlayer]);

            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);


           

        }

   
    </script>