在何处放置自动完成搜索框的HTML代码

在何处放置自动完成搜索框的HTML代码,html,google-maps,Html,Google Maps,下面的代码是我正在使用的代码。我试着阅读和观看谷歌开发者发布的YouTube视频。我是新手,需要一些帮助。我想在我的地图中放置自动完成搜索框。任何帮助都将不胜感激 <!DOCTYPE html> <html> <head> <title>Simple Map</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"&g

下面的代码是我正在使用的代码。我试着阅读和观看谷歌开发者发布的YouTube视频。我是新手,需要一些帮助。我想在我的地图中放置自动完成搜索框。任何帮助都将不胜感激

<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src=""http://maps.google.com/maps/api/js?libraries=places&sensor=false""></script>
    <script>
var map;
function initialize() {
  var mapOptions = {
    zoom: 13,
    center: new google.maps.LatLng(47.717312, -116.951370),
    disableDefaultUI: true,

  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);
  </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>
Javascript代码位于您所拥有的初始化中

我只是使用了来自的代码对此做了一个简单的描述

// Create the search box and link it to the UI element.
  var input = /** @type {HTMLInputElement} */(
      document.getElementById('pac-input'));
  map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);

  var searchBox = new google.maps.places.SearchBox(
    /** @type {HTMLInputElement} */(input));

  // Listen for the event fired when the user selects an item from the
  // pick list. Retrieve the matching places for that item.
  google.maps.event.addListener(searchBox, 'places_changed', function() {
    var places = searchBox.getPlaces();
function initialize(){
 //autocomplete code goes here.
}