我正在尝试简单地将 Google 搜索栏添加到我自己的地图上,但遇到了问题。我似乎无法让它工作!我试过 map.enableGoogleBar(); 但这只是摆脱了我的 KML 层并且没有添加搜索框!
这是代码:
function initialize() {
// set up startup options for the map
// disabled double click as it was annoying and streetview control removed.
var myOptions = {
zoom: 10,
//minZoom: 16,
center: new google.maps.LatLng(50.45750, -3.84521),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDoubleClickZoom: true,
streetViewControl: false,
mapTypeControl: true,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN,
position: google.maps.ControlPosition.TOP_LEFT
},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_LEFT
}
enableGoogleBar: true,
googleBarOptions: {showOnLoad:true},
};
// create the new map
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);