第1行: | 第1行: | ||
{{jspopularGL-sidebar}} | {{jspopularGL-sidebar}} | ||
− | <div class="h1-title">镂空多边形绘制</div><div id="update-time">更新时间:2020年10月22日</div><div class="bluetitle"><div class="services-title-text">简介</div></div><div class="serve-explain-text"> | + | <div class="h1-title">镂空多边形绘制</div><div id="update-time">更新时间:2020年10月22日</div><div class="bluetitle"><div class="services-title-text">简介</div></div><div class="serve-explain-text">镂空面绘制基于WebGL的模板取反处理,JSAPI GL提供的Polygon类可以实现镂空面绘制功能。<br/>当个传入的两个区域路径,一个区域位于另一个区域内部,则这个区域不会被绘制出来,从而实现”洞“的效果。</div><!--jsapi单独demo-代码--><div class="aloneDemo"><div dir="https://lbs.baidu.com/jsdemo/demo/fLoukongPolygon.htm"></div><div class="top_right">[http://lbs.baidu.com/jsdemo.htm#fLoukongPolygon DEMO详情]</div></div><div class="bluetitle"><div class="services-title-text">Polygon类参考</div></div><div class="serve-explain-text"> |
构造函数: | 构造函数: | ||
</div> | </div> | ||
第8行: | 第8行: | ||
| width="297" | '''说明''' | | width="297" | '''说明''' | ||
|- | |- | ||
− | | BMapGL. | + | | BMapGL.Polygon(points:Array< Point >, options) |
− | | | + | | 创建多边形覆盖物 |
|} | |} | ||
<div class="serve-explain-text"> | <div class="serve-explain-text"> | ||
第20行: | 第20行: | ||
| width="297" | '''说明''' | | width="297" | '''说明''' | ||
|- | |- | ||
− | | | + | | points |
− | | Point | + | | Array< Point > |
− | | | + | | 点坐标数组 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| options | | options | ||
| Object | | Object | ||
− | | | + | | 多边形样式自定义配置,可选 |
|} | |} | ||
<div class="serve-explain-text"> | <div class="serve-explain-text"> | ||
第41行: | 第37行: | ||
| width="297" | '''说明''' | | width="297" | '''说明''' | ||
|- | |- | ||
− | | | + | | strokeColor |
+ | | string | ||
+ | | 边线颜色 | ||
+ | |- | ||
+ | | fillColor | ||
+ | | string | ||
+ | | 填充颜色。当参数为空时,折线覆盖物没有填充效果。 | ||
+ | |- | ||
+ | | strokeWeight | ||
| number | | number | ||
− | | | + | | 边线宽度,以像素为单位 |
|- | |- | ||
− | | | + | | strokeOpacity |
| number | | number | ||
− | | | + | | 边线透明度,取值范围0-1 |
|- | |- | ||
− | | | + | | fillOpacity |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| number | | number | ||
− | | | + | | 填充透明度 |
|- | |- | ||
− | | | + | | strokeStyle |
− | | | + | | string |
− | | | + | | 边线样式,solid或dashed |
|} | |} | ||
− | <div class="bluetitle"><div class="services-title-text">使用示例</div></div><div class="devguide"><div class="leftborderbg" style="height:5000px;"></div><div class="devguideorder"><span>1</span>创建地图参照展示地图</div><div class="devguidecenter"></div><div class="devguideorder"><span>2</span> | + | <div class="bluetitle"><div class="services-title-text">使用示例</div></div><div class="devguide"><div class="leftborderbg" style="height:5000px;"></div><div class="devguideorder"><span>1</span>创建地图参照展示地图</div><div class="devguidecenter"></div><div class="devguideorder"><span>2</span>创建镂空多边形,并添加到地图上</div><div class="devguidecenter"> |
− | + | 镂空面绘制使BMapGL.Polygon类,第一个参数路径数组如果传入的是有相交的区域,则不绘制出来,实现“洞”的效果。如下例顺义区轮廓线存在相交区域,则内部区域镂空处理。 | |
<pre class="prettyprint codestyle"> var bd = new BMapGL.Boundary(); | <pre class="prettyprint codestyle"> var bd = new BMapGL.Boundary(); | ||
bd.get('顺义区', function (rs) { | bd.get('顺义区', function (rs) { |
2020年10月23日 (五) 10:31的版本
镂空多边形绘制
更新时间:2020年10月22日
简介
镂空面绘制基于WebGL的模板取反处理,JSAPI GL提供的Polygon类可以实现镂空面绘制功能。
当个传入的两个区域路径,一个区域位于另一个区域内部,则这个区域不会被绘制出来,从而实现”洞“的效果。
当个传入的两个区域路径,一个区域位于另一个区域内部,则这个区域不会被绘制出来,从而实现”洞“的效果。
Polygon类参考
构造函数:
构造函数 | 说明 |
BMapGL.Polygon(points:Array< Point >, options) | 创建多边形覆盖物 |
参数说明:
构造函数 | 类型 | 说明 |
points | Array< Point > | 点坐标数组 |
options | Object | 多边形样式自定义配置,可选 |
options属性变量:
options属性 | 类型 | 说明 |
strokeColor | string | 边线颜色 |
fillColor | string | 填充颜色。当参数为空时,折线覆盖物没有填充效果。 |
strokeWeight | number | 边线宽度,以像素为单位 |
strokeOpacity | number | 边线透明度,取值范围0-1 |
fillOpacity | number | 填充透明度 |
strokeStyle | string | 边线样式,solid或dashed |
使用示例
1创建地图参照展示地图
2创建镂空多边形,并添加到地图上
镂空面绘制使BMapGL.Polygon类,第一个参数路径数组如果传入的是有相交的区域,则不绘制出来,实现“洞”的效果。如下例顺义区轮廓线存在相交区域,则内部区域镂空处理。
var bd = new BMapGL.Boundary(); bd.get('顺义区', function (rs) { // console.log('外轮廓:', rs.boundaries[0]) // console.log('内镂空:', rs.boundaries[1]) var hole = new BMapGL.Polygon(rs.boundaries, { fillColor: 'blue', fillOpacity: 0.2 }); map.addOverlay(hole); });