Android Studio HEREMapSDKMap折线错误

u59ebvdq  于 2023-03-21  发布在  Android
关注(0)|答案(1)|浏览(98)
ArrayList<GeoCoordinates> coordinates = new ArrayList<>();
coordinates.add(new GeoCoordinates(52.53032, 13.37409));
coordinates.add(new GeoCoordinates(52.5309, 13.3946));
coordinates.add(new GeoCoordinates(52.53894, 13.39194));
coordinates.add(new GeoCoordinates(52.54014, 13.37958));
GeoPolyline geoPolyline;

try {
    geoPolyline = new GeoPolyline(coordinates);
} catch (InstantiationErrorException e) {
  geoPolyline = null;
}

float widthInPixels = 20;
Color lineColor = new Color((short) 0x00, (short) 0x90, (short) 0x8A, (short) 0xA0);
MapPolyline mapPolyline = new MapPolyline(geoPolyline, widthInPixels, lineColor);

我有上面的代码来制作MapPolyline,但是由于某种原因,它不允许我使用MapPolyline函数。

我收到此错误:

“com.here.sdk.mapviewlite.Map多段线”中的Map多段线(com. here. sdk.core.地理多段线,com.here.sdk.mapviewlite.Map多段线样式)不能应用于“(com.here.sdk.core.地理多段线,浮点型,com.here.sdk.core.颜色)”。
这些是我的进口货

import com.here.sdk.core.GeoCoordinates;
import com.here.sdk.core.GeoPolyline;
import com.here.sdk.core.errors.InstantiationErrorException;
import com.here.sdk.mapviewlite.MapPolyline;

任何帮助将不胜感激,谢谢
我可以在com.here.sdk.core中访问的所有其他包或函数

mwkjh3gx

mwkjh3gx1#

从报告的错误来看,MapPolyline()构造函数似乎不接受float作为第二个参数widthInPixels ...您必须定义MapPolylineStyle

MapPolylineStyle mapPolylineStyle = new MapPolylineStyle();
    mapPolylineStyle.setWidth(20);
    mapPolylineStyle.setColor(new Color((short) 0x00, (short) 0x90, (short) 0x8A, (short) 0xA0));
    MapPolyline mapPolyline = new MapPolyline(geoPolyline, mapPolylineStyle);

如建议here

相关问题