[Qgis-developer] Openlayers plugin and Virtual Earth (i.e.Bing Maps)

Noli Sicad nsicad at gmail.com
Thu Dec 2 22:35:27 EST 2010


Hi,

I am trying to add Virtual Earth (Bing Maps) to QGIS Openlayers plugin
and I have trouble on the projection of Bing Maps (i.e. alignment). My
shapefile layer (i.e.traces from the Google Maps) and other shapefile
layers are off when I overlayed the Bing map (Bing Hybrid).

Bing is far better Satellite imagery compare to Yahoo and Google. OSM
is using Bing for traces lately as result of Steve Coast (OSM founder)
working with Bing.

http://wiki.openstreetmap.org/wiki/File:Selecting_Bing_in_JOSM.png

I know that Bing uses different projection,
http://www.cadmaps.com/gisblog/?p=80


displayProjection: new OpenLayers.Projection("EPSG:4326"),

Inserting this code above does not help at all.

Here the entire code.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>OpenLayers Google Hybrid Layer</title>
    <style type="text/css">
        body {
            margin: 0;
        }
        #map {
            width: 100%;
            height: 100%;
        }
        .olLayerGoogleCopyright {
            left: 2px;
            bottom: 2px;
        }
        .olLayerGooglePoweredBy {
            left: 2px;
            bottom: 15px;
        }
        .olControlAttribution {
            font-size: smaller;
            right: 3px;
            bottom: 4.5em;
            position: absolute;
            display: block;
        }
    </style>
    <!-- this gmaps key generated for http://openlayers.org/dev/ -->
    <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
    <script src="OpenLayers.js"></script>
    <script type="text/javascript">
        var map;

        function init() {
            map = new OpenLayers.Map('map', {
                theme: null,
                controls: [],
                projection: new OpenLayers.Projection("EPSG:900913"),
		displayProjection: new OpenLayers.Projection("EPSG:4326"),
                units: "m",
                maxResolution: 156543.0339,
                maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34, 20037508.34, 20037508.34)
            });

            var gmap = new OpenLayers.Layer.Google(
                "Google Hybrid",
                {type: G_HYBRID_MAP, numZoomLevels: 19,
'sphericalMercator': true}
            );
            map.addLayer(gmap);
            map.setCenter(new OpenLayers.LonLat(0, 0), 2);
        }
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>

Any ideas how to solve this problem of non alignment of the layers using Bing.

Thanks.

Regards, Noli


More information about the Qgis-developer mailing list