BusStation
公交站点对象。
属性
| 属性 | 类型 | 描述 |
|---|---|---|
| name | String | 站点名称 |
| position | Point | 站点坐标 |
示例
ts
// 在公交线路搜索回调中处理 BusStation 对象
busLineSearch.onGetBusLineComplete = (result: BMapGL.BusLine) => {
const numStations = result.getNumBusStations();
for (let i = 0; i < numStations; i++) {
const station = result.getBusStation(i);
console.log('站点名称:', station.name);
console.log('站点坐标:', station.position);
// 在地图上标记站点
const marker = new BMapGL.Marker(station.position);
map.addOverlay(marker);
// 添加站点信息窗口
const infoWindow = new BMapGL.InfoWindow(station.name);
marker.addEventListener('click', () => {
infoWindow.open(marker);
});
}
};