我在尝试将图像作为地面叠加层添加到我正在创建的谷歌地图时遇到了困难。在我看到的所有帮助文件中,图像已作为 url 传递给地面覆盖函数。是否可以传入存储在我机器上的图像而不是在线图像?
这是我用于地图和叠加层的代码:
function initialize() {
var mapOptions = {
center: {lat: 45.3469, lng: -75.7594},
zoom: 10,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var imageBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(45.2118075, -75.4455767),
new google.maps.LatLng(45.2043559, -75.4545309));
var campusOverlay = new google.maps.GroundOverlay('Campus.JPG', imageBounds);
campusOverlay.setMap(map);
}
我希望将我创建的“Campus.jpg”图像添加到地图中。我也尝试过传递整个路径及其所有目录,但地图上仍然没有出现任何内容。如果没有办法像这样传递图像,有没有办法将图像放到网上并以这种方式使用它?
谢谢