最近需要在bing 地图上画圆,因为bing 地图没有直接提供画圆的API,画起来比较麻烦,经过在网上的查找终于找到了画圆的方法。下面的代码是我整理过的代码,其中画圆函数来至网络。因为画圆比较困难,所以分享给大家,让大家也少走弯路。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>bing map画圆</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript"
src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=zh-cn"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
map.SetZoomLevel(14);
var latLon=new VELatLong(34.79248399030799,113.69712352752688);
//设置地图中心点
map.SetCenter(latLon);
map.SetMouseWheelZoomToCenter(false);
//画圆,以地图中心latLon为圆心,半径为1km 画圆
drawCircle(latLon,1);
}
//画圆函数 origin 圆心,radius 半径 单位km
function drawCircle(origin, radius) {
var earthRadius = 6371;
//圆心纬度
var lat = (origin.Latitude * Math.PI) / 180;
//圆心经度
var lon = (origin.Longitude * Math.PI) / 180;
var d = parseFloat(radius) / earthRadius;
var points = new Array();
for (i = 0; i <= 360; i++) {
var point = new VELatLong(0, 0);
var bearing = i * Math.PI / 180;
point.Latitude = Math.asin(Math.sin(lat) * Math.cos(d) + Math.cos(lat) * Math.sin(d) * Math.cos(bearing));
point.Longitude = ((lon + Math.atan2(Math.sin(bearing) * Math.sin(d) * Math.cos(lat), Math.cos(d) - Math.sin(lat) * Math.sin(point.Latitude))) * 180) / Math.PI;
point.Latitude = (point.Latitude * 180) / Math.PI;
points.push(point);
}
var circle = new VEShape(VEShapeType.Polygon, points);
//设置无边缘
circle.SetLineColor(new VEColor(255, 0, 0, 0));
circle.HideIcon();
map.AddShape(circle);
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap'
style="position: relative; width: 400px; height: 400px;"></div>
</body>
</html>
分享到:
相关推荐
使用Silverlight Bing Map 加载Google Map,开发环境为vs2010,改程序通过本人测试,可以使用
这是我从微软window phone官网下载下来的,提供的是如何使用bing map的sample实例
全面的对GoogleMap和BingMap 的地图API进行分析,如果是做地图开发或做自己的GIS平台,应该是有帮助的
可以用于绘制三角图,如矿物,颗粒大小等等等
主要介绍了bing Map 在vue项目中的使用,需要的朋友可以参考下
Windows Phone 开发必备 Bing Map 使用方法
NULL 博文链接:https://zhao103804.iteye.com/blog/797428
SilverLight和BingMap做的车辆监控代码
用BingControl 实现google 混合地图,如有更好的,请给我留言谢谢.
MMM-Bingmap 基于必应地图的交通地图 需求Bing API创建一个帐户以使用api https://www.bingmapsportal.com/ 使用静态地图制作器来确定大小和位置 https://staticmapmaker.com/bing/ 设定档 { module: 'MMM-Bing...
用silverlight4 +bing 地图 写的一个demo ,与大家共勉。
BingMap的demo demo中展示了实例化地图,添加覆盖物(Marker),添加折线,多边形。
ArcBruTile display tiles from OpenStreetMap, Bing, Google, SpatialCloud and TMS/WMS-C Services in ArcGIS Desktop.
DLL de la bibliothèque Bing Map App SDK de Microsoft pour Silverlight
Silverlight富媒体特效地图实例,使用BingMap地图。
压缩包中包含 BingMaps头文件、 BingMaps.Resources.bundle、 libBingMaps.a 三个文件,导入到开发的项目中,直接可以使用bingMap。
Microsoft (Bing) Maps Angular 应用程序用于 Bing 地图的简单可重用 AngularJS 应用程序。 使用 AngularJS 1.2 和 Microsoft Maps Ajax Control 7.0。文档Microsoft 地图 API 参考: : AngularJS 1.2: ://code....
bing地图的开发sdk,用于silverlight 开发bing地图应用
微软必应·英雄会第三届在线编程大赛:几个bing? c++实现源代码。