2015-03-02 66 views
1

我在openstreetmap应用程序中使用了两个叠加层,Itemed叠加层和Path覆盖层叠加在一起。我想在路径覆盖和自定义标记内的路径中提供点击点击Openstreetmap中的路径

+0

你忘了提及你的框架。 – scai 2015-03-02 12:47:38

回答

0

最后我得到了回答上面的问题...

*所有的路径覆盖添加成单层... *在上一个水龙头检查isPointOnLine(LOX,洛伊,LTX,LTY,X, Y)

公共布尔isPointOnLine(双LOX,双洛伊,双LTX, 双LTY,双X,双Y){// 确定点是在线路 双DX = X - LOX; Double dy = y - loy; Double tx = ltx-lox; Double ty = lty - loy;

// normalise the line vector 
    Double t1 = new Double(1/Math.sqrt(tx * tx + ty * ty)); 

    tx *= t1; 
    ty *= t1; 

    // calculate inverse length of secondary vector 
    Double dl = new Double(1/Math.sqrt(dx * dx + dy * dy)); 

    // take dot product of normalised line vector, and rotated normalised 
    // secondary vector 
    Double dot = (dy * tx - dx * ty) * dl; 
    // Increase these values for less or more picky 
    if (dot < -0.2 || dot > 0.2) 
     return false; 

    // calculate distance along line segment by taking dot product of 
    // normalised 
    // line vector and un-normalised secondary vector 
    Double dis = tx * dx + ty * dy; 
    if (dis < 0 || dis > 1/t1) 
     return false; 

    return true; 
} 
0

不适用于PathOverlay。 使用OSMBonusPack Polyline

如果您只想打开气泡,请使用setInfoWindow。

如果您想做其他事情,请从Polyline类继承,重写onSingleTapConfirmed,然后使用isCloseTo。