-2

I'm currently using google map api v3 but google block my site. So I use my sub-domain temporarily and it work fine.

Now to prevent that happen again I will change my default map to openstreetmap. Now my question is how do i embed the other map like google, bing and etc to OSM.

I'll try this code but what happen is opposite, the OSM is embedded to google map

map.mapTypes.set("OSM", new google.maps.ImageMapType({ getTileUrl: function(coord, zoom) { return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; }, tileSize: new google.maps.Size(256, 256), name: "OpenStreetMap", maxZoom: 18 }));

Zero_73
  • 183
  • 3
  • 16

1 Answers1

-1

I found this link and think it is the one i look for. i can switch to OSM, Google, and Bing Map.

<script type='text/javascript' src='http://www.openlayers.org/api/OpenLayers.js'></script>
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=FALSE&libraries=drawing'></script>
<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>


var map = new OpenLayers.Map('map', {
    projection: new OpenLayers.Projection('EPSG:900913')
});
var osm = new OpenLayers.Layer.OSM();
var gmap = new OpenLayers.Layer.Google('Google street maps');
var bing = new OpenLayers.Layer.Bing({
    key: 'register your api key at bingmapsportal.com',
    type: 'Road',
    metadataParams: {mapVersion: 'v1'}
});
map.addLayers([osm, gmap, bing]);
map.setCenter(
    new OpenLayers.LonLat(2.2, 54.0).transform(
        new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()
    ), 5 );
map.addControl(new OpenLayers.Control.LayerSwitcher());

This can switch to a different webmap. If you have better than this let me know.

Zero_73
  • 183
  • 3
  • 16