Я хочу добавить Bing Maps pushpins со стороны сервера. Я попробовал код ниже, но кнопки не отображаются. Есть ли какие-либо предложения о том, как улучшить приведенный ниже код и сделать эту работу?Bing Maps pushpins не отображается
Я использую ASP.NET и C# для следующей программы с Bing Maps Ajax Control V7.0
C#:
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>
Извините за поздний ответ. Я тоже подозревал, что изменил свой код. Я тоже пробовал, но это не работает. Выше мой отредактированный код. –