0

我正在尝试从许多英国邮政编码动态生成 bing 地图。尽管可以使用硬编码位置的示例,但我正在努力寻找一个示例,该示例显示如何将邮政编码输入到 asp.net (VB) 文本框(或实际上是 5 个框)中,并且一旦单击按钮,这些变量将被传递给bing 地图并显示(不幸的是我的 Javascript 不是很好)

我一直在使用“交互式 SDK”,这个例子接近我想要的:http: //www.bingmapsportal.com/ISDK/AjaxV7#Pushpins5

有谁知道如何调整它,以便我可以传递几个文本框的值以在地图上显示几个图钉?

提前致谢

詹姆士

4

1 回答 1

0

Just curious, why do they need to be server side textbox?

Their json result request can handle just about any query you can throw at it. Simply concatenate your text boxes into a search query separated by commas.

function callSearchService(credentials) {
    var searchString =document.getElementById('txtStreetNum').value + ' ' +  document.getElementById('txtQueryStr').value + ' , ' + document.getElementById('txtQueryCity').value + ' , ' + document.getElementById('txtQueryState').value + ' , ' + document.getElementById('txtQueryPostal').value;
    var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?query=" + encodeURI(searchString) + "&output=json&jsonp=searchServiceCallback&key=" + credentials;
}

If for some reason, you really need to get the text from an asp.net text control (Maybe you want to pre-load it for a user), you can do it like this;

var aspTextBoxValue = '<%=ASPTextBox.Text%>';

To make it add different pushpins for different query box's you will need to do a few things:

  1. Concatenate separate searchStrings per query (callSearchService for each query)
  2. Make geocodeRequests for each query.
  3. Parse each result object and display the pushpin as seen in searchServiceCallback in the following example:

(Your example doesnt actually resemble and query / response parsing at all, here's one more suitable)

Query and Response in Bing Maps

Don't expect my syntax to be perfect, although it may be error free, I'm just getting you off on the right foot without doing it for you. :)

于 2012-09-24T18:58:33.130 回答