0
私はasp.net Webフォームを使用しており、bingマップにプッシュピンを挿入します。私はjquery ajaxコールを使用して、他のプロパティの間で経度と緯度を保持する写真のリストを取得します。asp.net Webフォームとienumerableを返す
HTML:
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<div style="width: 100px;">
<div style="float: left; width: 700px">
<asp:Panel ID="pnlMap" runat="server" Style="position: absolute; width: 600px; height: 450px;" />
</div>
</div>
Webメソッド:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
public static IEnumerable<Photo> GetAllVisiblePhotos()
{
using (SqlConnection conn = new SqlConnection(... return photos;
、それは本当に写真のリストを返します。
JavaScript関数は、次のとおりです。
function GetPhotos() {
$.support.cors = true;
try {
$.ajax({
url: 'Default.aspx/GetAllVisiblePhotos',
type: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: DisplayPics,
error: OnError
});
}
catch (err) {
alert(err.message);
}
}
function DisplayPics(response) {
var location;
var pin;
$.each(response, function (index, photo) {
location = new Microsoft.Maps.Location(photo.Latitude, photo.Longitude);
pin = new Microsoft.Maps.Pushpin(location);
pin.Title = photo.Title;
pin.ID = photo.PhotoID;
dataLayer.push(pin);
});
}
しかし、私は、地図上の任意の画鋲を得ることはありません。なにが問題ですか?