简体   繁体   English

正确调用方法“ buildRoadOverlay”

[英]Calling the method “buildRoadOverlay” correctly

I want to call the method buildRoadOverlay (Method is on the bottom of this post) from OSMdroid. 我想从buildRoadOverlay调用方法buildRoadOverlay (方法在这篇文章的底部)。 How do I set the parameters correctly? 如何正确设置参数?

This method builds a route on a map between two waypoints. 此方法在两个航点之间的地图上构建路线。 It works, as long as I leave out color and width when calling the method. 只要我在调用该方法时不留颜色和宽度,它就会起作用。 Now I want the color to be green and the width to be 20dp. 现在,我希望颜色为绿色,宽度为20dp。

This is how I tried it: 这是我尝试的方法:

Polyline roadOverlay = RoadManager.buildRoadOverlay(road, 7667507, 20);

The app starts, no errors, but the Line RoadOverlay does not get drawn anymore. 该应用程序启动,没有错误,但Line RoadOverlay不再绘制。 Either that or it is invisible. 要么就是它是不可见的。 I am not sure. 我不确定。

The method I want to call: 我要调用的方法:

public static Polyline buildRoadOverlay(Road road, int color, float width){
        Polyline roadOverlay = new Polyline();
        roadOverlay.setColor(color);
        roadOverlay.setWidth(width);
        if (road != null) {
            ArrayList<GeoPoint> polyline = road.mRouteHigh;
            roadOverlay.setPoints(polyline);
        }
        return roadOverlay;
    }

color is an Android Color . color是Android Color width is a float, in pixels. width是一个浮点数,以像素为单位。 So try: 因此,请尝试:

Polyline roadOverlay = RoadManager.buildRoadOverlay(road, Color.GREEN, 20.0f);

Putting some transparency on road shape is recommended, so that street names for instance remain visible. 建议在道路形状上添加一些透明度,以使街道名称保持可见。 So this will be better: 所以这会更好:

Polyline roadOverlay = RoadManager.buildRoadOverlay(road, 0x8000FF00, 20.0f);

(and yes, I apologize for the javadoc of this method. I will improve it) (是的,我为此方法的javadoc道歉。我将对其进行改进)

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

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