Appearance
批量添加多种覆盖物
调用方法
addOverlays(option)
返回值res.data
为唯一标识tag
数组,覆盖物的tag会在原tag基础上新增类型+索引,如:tag_marker_0
option
名称 | 类型 | 说明 |
---|---|---|
markers | markersListItem[] | marker数组 |
labels | labelsListItem[] | labels数组 |
lines | linesListItem[] | lines数组 |
polygons | polygonsListItem[] | polygons数组 |
circles | circlesListItem[] | circles数组 |
infoWindows | infoWindowsListItem[] | infoWindows数组 |
rectangles | rectanglesListItem[] | rectangles数组 |
imageOverlays | imageOverlaysListItem[] | imageOverlays数组 |
click | function | 点击覆盖物后会触发此事件 |
dblclick | function | 双击覆盖物后会触发此事件。 |
dragstart | function | 当用户拖动覆盖物时触发。 |
drag | function | 当用户拖动覆盖物时不断触发 |
dragend | function | 当用户停止拖动覆盖物时触发。 |
remove | function | 移除覆盖物时触发。 |
close | function | 信息窗口被关闭时触发此事件 |
open | function | 信息窗口被打开时触发此事件。 |
clickclose | function | 点击信息窗口的关闭按钮时触发此事件。 |
success | function | 调用成功回调 |
fail | function | 调用失败回调 |
示例代码
javascript
TDTRenderRef.value.addOverlays({
markers: [
{
lnglat: [106.48541, 29.62373],
options: {
icon: {
iconUrl: 'https://bearfun-dev.oss-accelerate.aliyuncs.com/v2/wxStatic/img/help-demo.jpg',
iconSize: [20, 20],
iconAnchor: [10, 10]
}
}
},
{
lnglat: [106.48541, 29.62573],
options: {
icon: {
iconUrl: 'https://bearfun-dev.oss-accelerate.aliyuncs.com/v2/wxStatic/img/help-demo.jpg',
iconSize: [20, 20],
iconAnchor: [10, 10]
}
}
}
],
labels: [
{
id: 1,
lnglat: [106.48541, 29.62373],
text: '123456',
offset: [0, 0]
},
{
id: 2,
lnglat: [106.49541, 29.62373],
text: '哇哈哈哈',
offset: [0, 0]
}
],
lines: [
{
points: [
[106.48562, 29.62385],
[106.48572, 29.62395],
[106.48962, 29.62485],
[106.48762, 29.62885]
]
},
{
points: [
[106.49562, 29.63385],
[106.49572, 29.63395],
[106.49962, 29.63485],
[106.49762, 29.63885]
]
}
],
polygons: [
{
points: [
[106.48562, 29.62385],
[106.48572, 29.62395],
[106.48962, 29.62485],
[106.48762, 29.62885]
]
},
{
points: [
[106.48662, 29.62885],
[106.48672, 29.62895],
[106.48662, 29.62985],
[106.48662, 29.62885]
]
}
],
circles: [
{
center: [106.48541, 29.62373],
radius: 100
},
{
center: [106.48541, 29.62473],
radius: 100
}
],
infoWindows: [
{
content: '我是一个粉刷匠',
lnglat: [106.48541, 29.62373]
},
{
content: '我是一个粉刷匠2222',
lnglat: [106.48741, 29.62573]
}
],
rectangles: [
{
lnglats: [
[106.48541, 29.62373],
[106.49541, 29.63373]
]
},
{
lnglats: [
[106.46541, 29.60373],
[106.48541, 29.62373]
]
}
],
imageOverlays: [
{
imageUrl: 'http://lbs.tianditu.gov.cn/images/openlibrary/gugong.jpg',
lngLatBounds: [
[106.48547, 29.62376],
[106.48647, 29.62476]
]
},
{
imageUrl: 'https://bearfun-dev.oss-accelerate.aliyuncs.com/v2/wxStatic/img/help-demo.jpg',
lngLatBounds: [
[106.48657, 29.62486],
[106.48757, 29.62586]
]
}
],
click: e => {
console.log('批量添加多种覆盖物', e);
}
});
贡献者
mosowe