Javascript nd.style.display='block'; legopenbutton.style.display='none'; } legendCloseButton.onclick=函数(){ legend.style.display='none'; leg

Javascript nd.style.display='block'; legopenbutton.style.display='none'; } legendCloseButton.onclick=函数(){ legend.style.display='none'; leg,javascript,jquery,google-maps,google-maps-api-3,Javascript,Jquery,Google Maps,Google Maps Api 3,nd.style.display='block'; legopenbutton.style.display='none'; } legendCloseButton.onclick=函数(){ legend.style.display='none'; legopenbutton.style.display='block'; } } var searchBox=new google.maps.places.searchBox(document.getElementById('pac-input');

nd.style.display='block'; legopenbutton.style.display='none'; } legendCloseButton.onclick=函数(){ legend.style.display='none'; legopenbutton.style.display='block'; } } var searchBox=new google.maps.places.searchBox(document.getElementById('pac-input'); var marker=new google.maps.marker({ 职位:新google.maps.LatLng(38.64936217820852,-90.53628850000001), 地图:地图, 真的, 标题:“你的新家”, }); marker.setMap(map); } google.maps.event.addDomListener(窗口“加载”,初始化)
html,
身体,
#谷歌地图画布{
高度:500px;
保证金:0;
填充:0;
宽度:100%;
}
.控制{
边缘顶部:10px;
边框:1px实心透明;
边界半径:2px 0 0 2px;
框大小:边框框;
-moz框大小:边框框;
高度:32px;
大纲:无;
盒影:0 2px 6px rgba(0,0,0,0.3);
}
#pac输入{
背景色:#fff;
字体系列:Roboto;
字体大小:15px;
字体大小:300;
左边距:12px;
填充:0 11px 0 13px;
文本溢出:省略号;
宽度:300px;
}
#pac输入:焦点{
边框颜色:#4d90fe;
}
.pac集装箱{
字体系列:Roboto;
}
#类型选择器{
颜色:#fff;
背景色:#4d90fe;
填充:5px11px 0px 11px;
}
#类型选择器标签{
字体系列:Roboto;
字体大小:13px;
字体大小:300;
}


您的HTML无效。如果我运行你的代码,我会得到一个javascript错误
uncaughtreferenceerror:LatLng未定义
我现在正试图让搜索框工作。我按照您的建议将这段代码放在初始化函数中,但现在没有映射正在呈现。
//搜索框google.maps.event.addListener上的place change事件(searchBox'places_changed',function(){//console.log(searchBox.getPlaces());var places=searchBox.getPlaces();//绑定的var bounds=new google.maps.LatLngBounds();var i,place;for(i=0;place=places{i};i++){console.log(place.geometry.location);bounds.extend(place.geometry.location);}map.fitbunds(bounds);map.setZoom(15)
这是另一个问题。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"></meta>
<title>Eastern Missouri School District Map  - Google Fusion Tables</title>
<style type="text/css">
html, body, #googft-mapCanvas {
  height: 500px;
  margin: 0;
  padding: 0;
  width: 100%;
}
.controls {
  margin-top: 10px;
  border: 1px solid transparent;
  border-radius: 2px 0 0 2px;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  height: 32px;
  outline: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#pac-input {
  background-color: #fff;
  font-family: Roboto;
  font-size: 15px;
  font-weight: 300;
  margin-left: 12px;
  padding: 0 11px 0 13px;
  text-overflow: ellipsis;
  width: 300px;
}

#pac-input:focus {
  border-color: #4d90fe;
}

.pac-container {
  font-family: Roboto;
}

#type-selector {
  color: #fff;
  background-color: #4d90fe;
  padding: 5px 11px 0px 11px;
}

#type-selector label {
  font-family: Roboto;
  font-size: 13px;
  font-weight: 300;
}
</style>

<input id="pac-input" class="controls" type="text"
placeholder="Enter your address here">
  <div id="googft-mapCanvas"></div>


<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false&amp;v=3"></script>

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>

<script type="text/javascript">

  function initialize() {
    google.maps.visualRefresh = true;
    var isMobile = (navigator.userAgent.toLowerCase().indexOf('android') > -1) ||
      (navigator.userAgent.match(/(iPod|iPhone|iPad|BlackBerry|Windows Phone|iemobile)/));
    if (isMobile) {
      var viewport = document.querySelector("meta[name=viewport]");
      viewport.setAttribute('content', 'initial-scale=1.0, user-scalable=no');
    }

    var mapDiv = document.getElementById('googft-mapCanvas');
    mapDiv.style.width = isMobile ? '100%' : '1000px';
    mapDiv.style.height = isMobile ? '100%' : '300px';
    var map = new google.maps.Map(mapDiv, {
      center: new google.maps.LatLng(38.64936217820852, -90.53628850000001),
      zoom: 9,
      mapTypeId: google.maps.MapTypeId.HYBRID
    });
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend-open'));
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend'));

    layer = new google.maps.FusionTablesLayer({
      map: map,
      heatmap: { enabled: false },
      query: {
        select: "col26",
        from: "11Q0B7iRayT2JIOBl8_VRUmitimhX1W01byuFDnAv",
        where: ""
      },
      options: {
        styleId: 2,
        templateId: 2
      }
    });

    if (isMobile) {
      var legend = document.getElementById('googft-legend');
      var legendOpenButton = document.getElementById('googft-legend-open');
      var legendCloseButton = document.getElementById('googft-legend-close');
      legend.style.display = 'none';
      legendOpenButton.style.display = 'block';
      legendCloseButton.style.display = 'block';
      legendOpenButton.onclick = function() {
        legend.style.display = 'block';
        legendOpenButton.style.display = 'none';
      }
      legendCloseButton.onclick = function() {
        legend.style.display = 'none';
        legendOpenButton.style.display = 'block';
      }
    }
  }


  google.maps.event.addDomListener(window, 'load', initialize);


  var searchBox = new google.maps.places.SearchBox(document.getElementById('pac-input'));


            var marker = new google.maps.Marker({
        position: LatLng(38.64936217820852, -90.53628850000001),
        map: map,
        draggable:true,
        title: "Your New Home",

    });
    marker.setMap(map);

</script> 
</head>

<body>
</body>
</html>
position: LatLng(38.64936217820852, -90.53628850000001),
position: google.maps.LatLng(38.64936217820852, -90.53628850000001),