如何在任何 HTML 页面中显示 bing 地图?
Bing 有一种他们称之为“AJAX 控件”的东西,可以动态地将生成的地图嵌入到任何网页中。有该控件的在线交互式演示。
我该如何使用这个控件?
Bing's got something they call "an AJAX control" that can dynamically embed generated maps into any webpage. There's an online interactive demo for the control.
How can I use this control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您提到的链接本身底部有一个查看 HTML 按钮,您可以单击它并抓取代码以在任何网页中显示。就像下面(我从你的链接中得到的):
The link you mentioned itself has a View HTML button on bottom, you can click it and grab the code to display in any webpage. Like below (which i got from your link):
使用大量 JavaScript?查看 http://www.bingmapsportal.com/ 网站,那里有充足的文档。
还有许多其他方法可以在站点中嵌入动态地图 - 请查看 GIS.stackexchange.com 的 JavaScript 映射库的比较。如果您有更具体的问题,我们很乐意在 GIS.se 上为您提供帮助。
With lots of JavaScript? Look on the http://www.bingmapsportal.com/ site where there is ample documentation.
There are also many other ways to embed a dynamic map in a site - take a look GIS.stackexchange.com's comparison of JavaScript mapping libraries. If you have more specific questions, we'll be happy to help over at GIS.se.
请参阅演示。
有一个 Javascript 类库,位于
http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol。 ashx?v=7.0
您需要将其包含到您的页面中,如下所示:
然后从 javascript 中调用它,如下所示:
要获取 bing 地图密钥,请转至 此页面。
您的 HTML 页面中需要一个具有该 id 的 div,并且其大小和样式应设置为位置:相对:
然后您可以向该地图添加信息框和图钉。
我还构建了一个 JavaScript 帮助程序,可以从 div 元素中提取自定义属性,并为您生成地图,并包含图钉和信息框。像这样:
然后 javascript:
包含帮助器类的 js 模块可在 jsfiddle 链接上找到。
See the demonstration.
There's a Javascript class library available at
http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0
You need to include it into your page like this:
And then call it from within javascript like this:
To get a bing maps key, go to this page.
You need a div with that id in your HTML page, and it should be sized and styled position:relative:
You can then add information boxes and pushpins to that map.
I also built a javascript helper that can extract custom attributes form the div element, and generate the map for you, complete with pushpins and infoboxes. like this:
And then the javascript:
The js module containing the helper class is available on the jsfiddle link.