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>