mssqlデータベースから緯度と経度を取得していますが、すべて機能していますが、同じデータベースの情報を使用して各マーカーをクリックして情報ウィンドウを追加したいのですが、どうすればよいかわかりません。
私の WebForm1.aspx.cs ページ:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;
using System.Windows.Forms;
using AjaxControlTolkit;
namespace WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection sqlConn;
SqlCommand sqlCmd;
SqlDataAdapter sqlDatatAdapter;
DataSet ds_pc;
protected void Page_Load(object sender, EventArgs e)
{
ds_pc = new DataSet();
sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
sqlCmd = new SqlCommand();
sqlDatatAdapter = new SqlDataAdapter();
sqlCmd = new SqlCommand("dbo.PROCEDURE", sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlDatatAdapter = new SqlDataAdapter(sqlCmd);
sqlDatatAdapter.Fill(ds_pc);
string Locations = "" ;
string txt_site ;
string lat ;
string lon ;
foreach(DataRow dr in (ds_pc.Tables[0]).Rows)
{
if (dr["LATITUDE"].ToString().Trim().Length == 0)
continue;
txt_site = dr["SITE"].ToString();
lat = dr["LATITUDE"].ToString();
lon = dr["LONGITUDE"].ToString();
Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + lat + "," + lon + ")));";
}
js.Text = @"<script type='text/javascript'>
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById('map_canvas'));
map.setCenter(new GLatLng(42.00, 43.30), 8);"+Locations+@"map.setUIToDefault();
}
}
</script> ";
}
}
私の WebForm1.aspx ページ:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Google Maps</title>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=MyKeyA&sensor=false"></script>
<body onload="initialize()" onunload="GUnload()">
<div>
<asp:Panel id="Panel1" runat="server">
<asp:Literal id="js" runat="server"></asp:Literal>
<div id="map_canvas" style="width: 1000px; height: 615px"></div>
</asp:Panel>
</div>
</body>
</html>
回答/提案はかなりのものです..ありがとう..