大佬教程收集整理的这篇文章主要介绍了jquery – 使用Bing Maps REST控件查找附近的实体,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如果有办法,这似乎很难记录.如果您上传自己的数据,有一些如何执行此操作的示例,但如果您正在搜索应该已经在地图上的本地商家,则不会这样做:Examples.这是我到目前为止所尝试的…它正在返回星巴克,俄勒冈州:
var query = 'starbucks'; _map.getCredentials(function (credentials) { $.getJSON('http://dev.virtualearth.net/REST/V1/LOCATIOns/' + query + '?key=' + credentials + '&lat=' + position.coords.latitude + '&long=' + position.coords.longitude + '&limit=25&jsonp=?&s=1',function (result) { if (result.resourceSets[0].address != 'undefined') { var address = result.resourceSets[0].address; alert(address); } else { $("#results").html("Oops! It appears one or more of the addresses you entered are incorrect. :( "); } }); });
这是位置查询之前的代码,以防您想知道我在位置查询中使用的位置数据是什么 – 它主要来自用户通过地理定位API的位置:
var _map; $(document).ready(function () { if (Modernizr.geoLOCATIOn) { $(".geofallBACk").hide(); } else { $(".geofallBACk").show(); } $.post("Home/Key",{ "func": "Key" },function (data) { // Create a Bing map _map = new Microsoft.Maps.Map(document.getElementById("map"),{ credentials: data,mapTypEID: Microsoft.Maps.MapTypEID.ordnanceSurvey }); }); // Get the current position from the browser if (!navigator.geoLOCATIOn) { $("#results").html("This browser doesn't support geoLOCATIOn,please enter an address"); } else { navigator.geoLOCATIOn.getCurrentPosition(onPositionReady,onError); } }); function onPositionReady(position) { // Apply the position to the map var LOCATIOn = new Microsoft.Maps.LOCATIOn(position.coords.latitude,position.coords.longitudE); _map.setView({ zoom: 18,center: LOCATIOn }); // Add a pushpin to the map represenTing the current LOCATIOn var pin = new Microsoft.Maps.Pushpin(LOCATIOn); _map.entities.push(pin); var query = 'starbucks'; _map.getCredentials(function (credentials) { $.getJSON('http://dev.virtualearth.net/REST/V1/LOCATIOns/' + query + '?key=' + credentials + '&lat=' + position.coords.latitude + '&long=' + position.coords.longitude + '&limit=25&jsonp=?&s=1',function (result) { if (result.resourceSets[0].address != 'undefined') { var address = result.resourceSets[0].address; alert(address); } else { $("#results").html("Oops! It appears one or more of the addresses you entered are incorrect. :( "); } }); }); }
任何帮助将不胜感激!!
以上是大佬教程为你收集整理的jquery – 使用Bing Maps REST控件查找附近的实体全部内容,希望文章能够帮你解决jquery – 使用Bing Maps REST控件查找附近的实体所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。