简体   繁体   中英

OpenLayers to display google maps

I am trying to display google maps in my web application but it displays blank. My map.js is as follows

var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'http://maps.google.com/maps/api/js?sensor=false';
head.appendChild(script);

map = new OpenLayers.Map({
    div: "map",
    allOverlays: true
});

var google_map_layer = new OpenLayers.Layer.Google('Google Map Layer', {});

map.addLayer(google_map_layer);

I am using openlayers version 2.10. Where am I going wrong? Please help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM