Google maps 谷歌地图搜索框外的地图,与地图
嗨,我一直在尝试创建一个具有搜索功能的谷歌地图。出于某种原因,搜索框可以工作,但是搜索功能在我的地图上实现了,我不确定为什么 我基本上希望地图外的搜索框更新地图,并设置位置Google maps 谷歌地图搜索框外的地图,与地图,google-maps,google-maps-api-3,google-api,Google Maps,Google Maps Api 3,Google Api,嗨,我一直在尝试创建一个具有搜索功能的谷歌地图。出于某种原因,搜索框可以工作,但是搜索功能在我的地图上实现了,我不确定为什么 我基本上希望地图外的搜索框更新地图,并设置位置 function init(){ var maxZoom = 3; var locationZoom = 5; var markers = []; var mapOptions = { zoom:
function init(){
var maxZoom = 3;
var locationZoom = 5;
var markers = [];
var mapOptions = {
zoom: maxZoom,
minZoom: maxZoom,
center: new google.maps.LatLng(31.631095, -7.954125),
};
var mapElement = document.getElementById('google-map');
var map = new google.maps.Map(mapElement, mapOptions);
new google.maps.places.Autocomplete(
(document.getElementById('autocomplete')), {
types: ['geocode']
});
}
init();
我的Html
<div class="row google-search">
<div class="col-sm-12">
<input id="autocomplete" class="form-control" type="text" placeholder="Search Box">
</div>
</div>
<div id="google-map"></div>
<script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
您需要通过监听AutoComplete上的更改将这两件事联系在一起-啊,我明白了,只是一直在尝试查找此文档