简体   繁体   English

这里是Maps Javascript API-信息气泡叠加路线折线吗?

[英]Here Maps Javascript API - Information bubble overlaying route polyline?

I render a map with a route from point A to point B and zoom to the bounding box of the route. 我渲染了具有从A点到B点的路线的地图,并缩放到该路线的边界框。

I also render an associated information bubble for point B (destination). 我还为B点(目标)绘制了一个相关的信息气泡。 This specific portion of my application does not involve user intervention so it is completely unattended The map is also printed Point B is always different using Enterprise Javascript API v2.5.4 我的应用程序的这一特定部分不涉及用户干预,因此完全无人值守。打印的地图B点使用Enterprise Javascript API v2.5.4总是不同的

My issue is that many times the info bubble overlays the route polyline which obstructs the route. 我的问题是很多时候信息气泡会覆盖阻碍路线的路线折线。

I see InfoBubble alignment options for left, right, above, below but these will not help as points are dynamic 我看到了左,右,上,下的InfoBubble对齐选项,但由于点是动态的,这些选项无济于事

Any suggestions on positioning of Info Bubble to assure it does not overlay route? 关于定位信息气泡以确保其不会覆盖路线的任何建议?

The defaultXAlignment and defaultYAlignment properties can be used to set a preferred position of the InfoBubble. defaultXAlignmentdefaultYAlignment属性可用于设置InfoBubble的首选位置。

You can use the defaultXAlignment and defaultYAlignment properties to alter the preferred offset for the Infobubble eg: 您可以使用defaultXAlignmentdefaultYAlignment性质改变了的首选偏移Infobubble例如:

var infoBubbles = new nokia.maps.map.component.InfoBubbles();
infoBubbles.options.set("defaultXAlignment", 
    nokia.maps.map.component.InfoBubbles.ALIGNMENT_RIGHT);
infoBubbles.options.set("defaultYAlignment",
     nokia.maps.map.component.InfoBubbles.ALIGNMENT_ABOVE);
map.components.add(infoBubbles);

In your case I would suggest the following. 对于您的情况,我建议以下内容。

  • When you zoom to the bounding box of the route add a padding factor to ensure there is space to display the infoBubble. 缩放到路线的bounding box ,请添加一个填充因子,以确保有足够的空间来显示infoBubble。 The simplest way would be to zoom out one more stop, but you could use the padding property of the nokia.maps.map.Display to ensure you have enough space when you zoom() . 最简单的方法是缩小一个停靠点,但是可以使用nokia.maps.map.Displaypadding属性来确保zoom()时有足够的空间。 See nokia.maps.map.Display.setPadding() 参见nokia.maps.map.Display.setPadding()

  • Secondly calculate the bearing between the start and endpoints: 其次,计算起点和终点之间的方位

     Number.prototype.toRad = function() { // convert degrees to radians return this * Math.PI / 180; } function bearing(lat1, lon1, lat2, lon2) { lat1 = lat1.toRad(); lat2 = lat2.toRad(); var dLon = (lon2-lon1).toRad(); var y = Math.sin(dLon) * Math.cos(lat2); var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); return Math.atan2(y, x); } 
  • If the result is between 0 and Math.PI/2 you are travelling North-East fix the Infobubble to display on the right and above . 如果结果介于0和Math.PI/2之间,则说明您正向东北行驶,请修复信息气泡,使其显示在右侧上方

  • If the result is between Math.PI/2 and Math.PI you are travelling South-East fix the Infobubble to display on the right and below . 如果结果介于Math.PI/2Math.PI之间,则说明您正向东南行驶,请修复信息气泡,使其显示在右侧下方
  • If the result is between -Math.PI and -Math.PI/2 you are travelling South-West fix the Infobubble to display on the left and below . 如果结果介于-Math.PI-Math.PI/2之间,则-Math.PI/2您正在西南航行,请修复Inf​​obubble以在左侧下方显示。
  • If the result is between -Math.PI/2 and 0 you are travelling North-West fix the Infobubble to display on the left and above . 如果结果在-Math.PI/2和0之间,则-Math.PI/2您正在向西北行驶时将Infobubble修复为显示在左侧上方

You can find more information about completely fixing an InfoBubble the answer here 您可以在此处找到有关完全修复InfoBubble的更多信息,答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM