【问题标题】:I want to search and find the location and weather details in weather map我想在天气图中搜索并找到位置和天气详细信息
【发布时间】:2014-09-01 12:18:27
【问题描述】:

我在此应用程序中添加了一个文本框和搜索按钮。我想输入一个位置并单击搜索按钮,然后它会显示带有天气详细信息的适当位置。我尝试了很多方法,但都行不通。所以谁有代码,然后请与我分享。 谢谢你。

<!DOCTYPE html>

<html>
  <head id="Head1" runat="server">
    <meta charset="utf-8">
    <title>Weather layer</title>


    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=weather"></script>
    <script>
        function initialize() {
            var mapOptions = {
                center: new google.maps.LatLng(12.9667, 77.5667),
                zoom: 6,
                mapTypeId: google.maps.MapTypeId.WeatherLayer
            };

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

            var weatherLayer = new google.maps.weather.WeatherLayer({
                temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT
            });
            weatherLayer.setMap(map);

            var cloudLayer = new google.maps.weather.CloudLayer();
            cloudLayer.setMap(map);
        }

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

    </script>

  </head>
  <body>
      <form id="form1" runat="server">
    <div id="map-canvas"style="height:400px;width:400px;"></div>
  <asp:Button ID="Button1" runat="server" Text="Proceed" />
          <input id="searchTextField" type="text" size="50"style="height:auto;width:320px;">
          </form>
  </body>
</html>

【问题讨论】:

  • 那么问题出在哪里?似乎 GridView 中只有 2 列或更少的列
  • 记住列是从零开始的
  • GridView1.Columns[2].Visible = false;
  • @Cheese 我在 gridview 中有 4 列。我想通过单击按钮删除或隐藏运行时列之一。?

标签: c# asp.net google-maps google-weather-api


【解决方案1】:

您可以将其隐藏,而不是删除您的列

protected void Button4_Click(object sender, EventArgs e)
{          
   GridView1.Columns[2].Visible = False;
}

但是,由于它给您一个Index was out of range 异常,因此您的网格中可能不存在第三列。好像你想隐藏第二列,所以你应该写

GridView1.Columns[1].Visible = False;

因为网格列的索引从零开始。

【讨论】:

    猜你喜欢
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-09
    • 1970-01-01
    • 2011-08-27
    • 2013-01-15
    • 2012-03-29
    相关资源
    最近更新 更多