0
如果我訂閱了Google Maps API,但未訂閱Google Places API,但是有可能從搜索詞找到位置地點?搜索沒有地點的Google地圖框
類似的東西來this CODEPEN(使用場所)
(function() {
var marker;
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var input = document.getElementById('search');
var searchBox = new google.maps.places.SearchBox(input);
google.maps.event.addListener(searchBox, 'places_changed', updateMap);
function updateMap() {
var places = searchBox.getPlaces();
var place = places[0];
var radius = 1000000;
if (marker) { marker.setMap(null); }
marker = new google.maps.Marker({
map: map, title: place.name,
position: place.geometry.location
});
var circle = new google.maps.Circle({
center: marker.position, radius: radius
});
map.fitBounds(circle.getBounds());
}
})();
<input id="search" type="text" placeholder="Search Here">
<h2/>
<div id="map"></div>