Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions); 多段线.setMap(map); } //结束 第一学校 学校2 您的选择下拉菜单有哪些选项?不同的_Javascript_Jquery_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions); 多段线.setMap(map); } //结束 第一学校 学校2 您的选择下拉菜单有哪些选项?不同的

Javascript var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions); 多段线.setMap(map); } //结束 第一学校 学校2 您的选择下拉菜单有哪些选项?不同的,javascript,jquery,google-maps,google-maps-api-3,Javascript,Jquery,Google Maps,Google Maps Api 3,var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions); 多段线.setMap(map); } //结束 第一学校 学校2 您的选择下拉菜单有哪些选项?不同的位置/路径或不同的多段线笔划?更新问题并在“选择”下拉列表中显示您的HTML。您想更新地图上的哪些信息?我已使用“选择”按钮进行了更新。单击学校时,下拉列表将显示学校列表。。它将显示一条路线,即路线638..因此,根据代码,我想每个学校都有不同

var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions); 多段线.setMap(map); } //结束 第一学校 学校2
您的选择下拉菜单有哪些选项?不同的位置/路径或不同的多段线笔划?更新问题并在“选择”下拉列表中显示您的HTML。您想更新地图上的哪些信息?我已使用“选择”按钮进行了更新。单击学校时,下拉列表将显示学校列表。。它将显示一条路线,即路线638..因此,根据代码,我想每个学校都有不同的多段线(路线)?是的,这是正确的,谢谢。您认为可以将其拆分并显示代码plz。。我正在努力让它工作!:(我已经在上面的原始问题中添加了我的完整代码,这更近了一步,但它只显示一个空白的灰色画布,没有地图..不确定我是否正确输入了多段线?我收到错误“多段线未定义[Break On This error]polyline.setMap(地图);”在firebug中。你包括google maps javascript库了吗?我现在看到了你的编辑…当你调用updateMap(mapchange)方法时,你必须将select控件作为参数传递。好吧,我该怎么做?我承认JS不是最好的。(非常感谢你在这方面的帮助!)
        <script>
    // Mapping variables
            var global_strokeColor = "#FF0000";
            var global_strokeOpacity = 1.0;
            var global_strokeWeight = 2;

            //BROMLEY BOROUGH
            var bromley_centrepoint = new google.maps.LatLng(51.408664,0.114405);

            var school_bromley_beaverwood = new google.maps.LatLng(51.41859298,0.089179345);
            var school_bromley_bishpjustus = new google.maps.LatLng(51.382522,0.045018);

            // Route 638
            var bromley_route638 = new google.maps.Polyline({
              path: [new google.maps.LatLng(51.408664,0.114405),new google.maps.LatLng(51.412973,0.114973),new google.maps.LatLng(51.417979,0.097195),new google.maps.LatLng(51.421214,0.023720)],
              strokeColor: global_strokeColor,
              strokeOpacity: global_strokeOpacity,
              strokeWeight: global_strokeWeight
            });

          function initialize() {
            var myLatLng = bromley_centrepoint;
            var myOptions = {
              zoom: 13,
              center: myLatLng,
              mapTypeId: google.maps.MapTypeId.TERRAIN
            };


           var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

           bromley_route638.setMap(map);

          }
        </script>
        </head>
        <body onload="initialize()">
          <div id="map_canvas"></div>
<div id="asd">
  <form style="float:left; ">
      <select name="mapchange">
        <option onclick="">school 1</option>
        <option onclick="">school 2</option>
    </select>
  </form>
</div>

        </body>
        </html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Bus Routes</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">

    function updateMap(selectControl)   {
        switch(selectControl.value)
        {
    case school1:
      var polyline = new google.maps.Polyline({
  path: [
  new google.maps.LatLng(51.408664,0.114405),
  new google.maps.LatLng(51.412973,0.114973),
  new google.maps.LatLng(51.417979,0.097195),
  new google.maps.LatLng(51.421214,0.023720)],
  strokeColor: "#FF0000",
  strokeOpacity: 1.0,
  strokeWeight: 2
});

      var latLng = new google.maps.LatLng(51.41859298,0.089179345)
      break;
    case school2:
      var polyline = new google.maps.Polyline({
  path: [
  new google.maps.LatLng(51.408664,0.114405),
  new google.maps.LatLng(51.412973,0.114973),
  new google.maps.LatLng(51.417979,0.097195),
  new google.maps.LatLng(51.421214,0.023720)],
  strokeColor: "#FF0000",
  strokeOpacity: 1.0,
  strokeWeight: 2

  });

      var latLng = new google.maps.LatLng(51.382522,0.045018)
      break;
    default:
      break;
    }
    initialize(polyline, latLng);
    }

    function initialize(polyline, schoolLatLng) {
        var myLatLng = schoolLatLng;
        var myOptions = {
          zoom: 13,
          center: myLatLng,
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };


       var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

       polyline.setMap(map);

      }

    //end

</script>

</head>

<body onload="initialize()">

<div id="map" style="width:600px; height:600px; display:block;">
    <div id="map_canvas" style="width:600px; height:600px;"></div>
</div>

<form style="float:left; ">
    <select name="mapchange">
        <option onchange="updateMap" value="school1">school 1</option>
        <option onchange="updateMap" value="school2">school 2</option>
    </select>
</form>

</body>



   </

html>
<select name="mapchange">
    <option onclick="updateMap">school 1</option>
    <option onclick="updateMap">school 2</option>
</select>
switch(dropdownvalue)
polyline.setMap(map);
<select name="mapchange" onchange="updateMap(this.options[this.selectedIndex].value)>
<option value="school1">school 1</option>
<option value="school2">school 2</option>
</select>
function updateMap(selectControl)
{
switch(selectControlValue)
{

case 'school1':
  var polyline = new google.maps.polyline....
  var latLng = new google.maps.LatLng(the coordinates of the school)
  break;
case 'school2':
  var polyline = new google.maps.polyline....
  var latLng = new google.maps.LatLng(the coordinates of the school)
  break;
default:
  break;
}
initialize(polyline, latLng);
}
function initialize(polyline, schoolLatLng) {
        var myLatLng = schoolLatLng;
        var myOptions = {
          zoom: 13,
          center: myLatLng,
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };


       var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

       polyline.setMap(map);

      }
    <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Bus Routes</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">

    function updateMap(selectControl)   {
    alert(selectControl);
        switch(selectControl)
        {
    case 'school1':
      var polyline = new google.maps.Polyline({
  path: [
  new google.maps.LatLng(51.408664,0.114405),
  new google.maps.LatLng(51.412973,0.114973),
  new google.maps.LatLng(51.417979,0.097195),
  new google.maps.LatLng(51.421214,0.023720)],
  strokeColor: "#FF0000",
  strokeOpacity: 1.0,
  strokeWeight: 2
});

      var latLng = new google.maps.LatLng(51.41859298,0.089179345)
      break;
    case 'school2':
      var polyline = new google.maps.Polyline({
  path: [
  new google.maps.LatLng(51.408664,0.114405),
  new google.maps.LatLng(51.412973,0.114973),
  new google.maps.LatLng(51.417979,0.097195),
  new google.maps.LatLng(51.421214,0.023720)],
  strokeColor: "#FF0000",
  strokeOpacity: 1.0,
  strokeWeight: 2

  });

      var latLng = new google.maps.LatLng(51.382522,0.045018)
      break;
    default:
      break;
    }
    initialize(polyline, latLng);
    }

    function initialize(polyline, schoolLatLng) {
        var myLatLng = schoolLatLng;
        var myOptions = {
          zoom: 13,
          center: myLatLng,
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };


       var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

       polyline.setMap(map);

      }

    //end

</script>

</head>

<body onload="initialize()">

<div id="map" style="width:600px; height:600px; display:block;">
    <div id="map_canvas" style="width:600px; height:600px;"></div>
</div>

<form style="float:left; ">
    <select name="mapchange" onchange="updateMap(this.options[this.selectedIndex].value)">
        <option  value="school1">school 1</option>
        <option  value="school2">school 2</option>
    </select>
</form>

</body>



   </html>