我想在我的项目中使用 Google Maps for Openlayers。我尝试将地图与此集成:https ://github.com/mapgears/ol3-google-maps 。但我什至无法得到最简单的例子。地图未加载(空白),并且在控制台中我得到“ReferenceError:olgm 未定义”。这是我的代码:
<script>
...code...
var googleLayer = new olgm.layer.Google();
var center = [-7908084, 6177492];
var map = new ol.Map({
interactions: olgm.interaction.defaults(),
controls: ol.control.defaults().extend([
overviewMapControl,
mousePositionControl,
new ol.control.ScaleLine()
]),
layers: [googleLayer],
target: 'map',
view: new ol.View({
center: center,//[0, 0],
zoom: 2
})
});
var olGM = new olgm.OLGoogleMaps({map: map}); // map is the ol.Map instance
olGM.activate();
...code...
</script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&key=MYKEYHERE"></script>
<script src="js/ol3gm-debug.js"></script>
我可能会做错什么?