2015-03-02 67 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。