使用gmap4rails,我在rails应用程序中创建了一个带有一些标记的地图。现在我想在我创建的地图上添加一个自定义地图的groundOverlay。我在Google MAPS API(https://developers.google.com/maps/documentation/javascript/groundoverlays)中找到了一些文档,但我无法找到使用gmap4rails执行此操作的正确语法。现在有人怎么做?
到目前为止我的代码:
<% content_for(:after_js) do %>
<%= javascript_tag do %>
var strictBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(52.346415, 4.853680),
new google.maps.LatLng(52.402162, 4.978654)
);
$(document).on('ready', function(){
handler = Gmaps.build('Google');
handler.buildMap({
internal: {id: 'map'},
provider: {
zoom: 13,
center: new google.maps.LatLng(52.373095,4.8909129,17),
mapTypeId: google.maps.MapTypeId.ROADMAP,
draggable: true,
styles: mapStyle
}
},
function(){
markers = handler.addMarkers(<%= raw @markers.to_json %>);
handler.bounds.extendWidth(markers);
handler.fitMapToBounds();
});
})
<% end %>
<% end %>
我想添加这样的内容:
groundoverlay: {
options: {
url: "custommap.jpg",
bounds: {
sw: {
lat: 52.346415,
lng: 4.853680
},
ne: {
lat: 52.402162,
lng: 4.978654
}
},
opts: {
opacity: 1
}
}
}