点击OpenStreetMap的路径内 [英] Click inside the Path in Openstreetmap

查看:106
本文介绍了点击OpenStreetMap的路径内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个覆盖在我的OpenStreetMap的应用程序,逐项叠加和位移叠加在一起。我想提供点击路径叠加和定制标记

I have two overlays in my openstreetmap app, Itemized overlay and Path overlay together. I want to provide click inside the path inside the path overlay and custom marker

推荐答案

最后,我得到了答案上述问题...

Finally I got answer for the Above question...

*将所有路径叠加成单层... *在对单一的水龙头检查isPointOnLine(LOX,洛伊,LTX,LTY,X,Y)

*Add all path overlays into a single layer... *In on single tap check isPointOnLine(lox,loy,ltx,lty, x, y)

公共布​​尔isPointOnLine(双熏鲑鱼,双洛伊,双LTX,             双LTY,双X,双Y){         //确定的一点是在线         双DX = X - LOX;         双DY = Y - 洛伊;         双TX = LTX - LOX;         双TY = LTY - 洛伊;

public boolean isPointOnLine(double lox, double loy, double ltx, double lty, double x, double y) { // determine if point is on line Double 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;
}

这篇关于点击OpenStreetMap的路径内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆