html - (ngx-openlayers) - 悬停在线串时显示工具提示
问题描述
如图所示,我没有为每个线串分配名称,而是尝试在用户将鼠标悬停在字符串上时显示工具提示。我目前正在使用 ngx-openlayers 来显示该行的名称。
lines : Array<{ a: number; b: number; c: number;d: number;id: string;name: string, width: number}> =
[
{a:11.5820,b:48.1351,c:13.388866,d:52.517071,id:"line-1",name:"line-1", width:19}
];
<aol-feature *ngFor="let l of lines" [id]="l.id">
<aol-geometry-linestring >
<aol-collection-coordinates
[coordinates]="[[l.a, l.b],[l.c, l.d]]"
[srid]="'EPSG:4326'">
</aol-collection-coordinates>
</aol-geometry-linestring>
<aol-style>
<aol-style-stroke [width]="l.width" [color]="'yellow'"></aol-style-stroke>
<aol-style-text [text]="l.id" [rotation]="'5'" [textBaseLine]="'middle'" [textAlign]="'center'"></aol-style-text>
</aol-style>
</aol-feature>
有人可以帮我弄这个吗?
提前致谢。
更新:我设法根据我分配的内容获取了该行的 ID。现在我想在每次用户将鼠标悬停到线串时都有一个关于该功能的工具提示。
displayTooltip(evt) {
console.log(evt);
const map = evt.map;
const p = map.forEachFeatureAtPixel(evt.pixel,
function(feature, layer) {
console.log("got feature" + feature.getId());
return feature;
});
}
解决方案
推荐阅读
- stripe-payments - 如何将 Stripe 的 API 的 risk_score 提高到 99?
- python - 对 Python 数据框中的一列求和
- android - jetpack compose 是否使用 drawable-night 文件夹?
- oracle - 使用总列的动态行到列转换
- reactjs - 在类组件中反应 useTranslation 替代方案
- android - 在数据库android中插入时间戳列
- excel - VBA UserForms noModal和Modal交互问题
- javascript - chrome 扩展通过共享本地存储将多条消息传递到外部站点
- html - 使用固定位置滚动左侧菜单
- javascript - Node.js Express.js 发送 Jquery Ajax Post 抛出常量错误 - 我被卡住了