1
서버 측에서 Bing지도 압핀을 추가하고 싶습니다. 아래 코드를 시도했지만 압핀이 나타나지 않습니다. 아래 코드를 개선하고이 작업을 수행하는 방법에 대한 제안 사항이 있습니까?Bing지도 압핀이 나타나지 않음
protected void Page_Load(object sender, EventArgs e)
{
GetLocation(sender,e);
}
protected void GetLocation(object sender, EventArgs e)
{
DataTable tblLocation = new DataTable();
string query = "SELECT Latitude, Longitude FROM Location ";
if (textbox1.Text != "")
{
textbox1.Text = Convert.ToString(Convert.ToInt32(textbox1.Text) + 1);
}
else
{
textbox1.Text = "1";
}
query += " WHERE num = " + textbox1.Text;
SqlDataAdapter adapter = new SqlDataAdapter();
string connString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
conn.Open();
adapter.SelectCommand = new SqlCommand(query, conn);
adapter.Fill(tblLocation);
conn.Close();
if (tblLocation.Rows.Count > 0)
{
longitude.Text = tblLocation.Rows[0]["Longitude"].ToString();
latitude.Text = tblLocation.Rows[0]["Latitude"].ToString();
string script = "UpdatePushPin(+ " + latitude.Text + " , " + longitude.Text + ");";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Key", script, true);
}
else
{
textbox1.Text = Convert.ToString(Convert.ToInt32(textbox1.Text) - 1);
}
}
Asp.net :
<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>
<script type='text/javascript'>
var map;
function GetMap() {
map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
{credentials: "mycredentials",
center: new Microsoft.Maps.Location(12.2, 103.7),
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 12
});
}
function UpdatePushPin(x, y) {
map.entities.clear();
var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(x, y));
map.entities.push(pushpin);
}
</script>
죄송합니다. 나는 또한 나의 코드를 바꿨다는 것을 의심했다. 나는 너의 것을 시도했지만 효과가 없다. 위의 코드는 수정 된 코드입니다. –