在我的页面中,我需要一个示例来使用bingmapApi通过提供ipaddress作为输入来查找邮政编码,我尝试过将地址作为输入并显示纬度和经度
我用于显示下面的纬度和经度的代码
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSearch").click(function () {
//check user has entered something first
if ($("#txtAddress").val().length > 0) {
//send location query to bing maps REST api
$.getJSON('http://dev.virtualearth.net/REST/v1/Locations?query=' + $("#txtAddress").val() + '&key=mykey&jsonp=?', function (result) {
if (result.resourceSets[0].estimatedTotal > 0) {
var loc = result.resourceSets[0].resources[0].point.coordinates;
$("#results").html('latitude:' + loc[0] + ', longitude:' + loc[1]);
}
else {
$("#results").html("sorry that address cannot be found");
}
});
}
else {
$("#results").html("please enter an address");
}
});
});
</script>
<label for="myaddress">Type an address:</label>
<input type="text" id="txtAddress" />
<input type="button" id="btnSearch" value="Find Location" />
<p id="results"></p>
真的我想做的是,通过提供IP地址作为输入,使用bingmapAPI显示邮政编码。提前谢谢。