【问题标题】:Gardient polyline in android googlemapandroid谷歌地图中的渐变折线
【发布时间】:2020-12-15 15:03:48
【问题描述】:

我正在使用Google Maps 开发应用程序,我想更改地图上polyline 的样式。我想将折线的颜色更改为渐变线,如何在 Android 中执行此操作。

【问题讨论】:

标签: google-maps google-maps-android-api-2


【解决方案1】:

你可以使用我的richmaps库:https://github.com/antoniocarlon/richmaps

您可以像这样轻松创建渐变折线:

RichPolylineOptions polylineOpts = new RichPolylineOptions(null)
        .zIndex(3) // zIndex represents the position of the polyline on the RichLayer
        .strokeWidth(15)
        .strokeColor(Color.YELLOW) // Set the polyline base color
        .linearGradient(true)
        .add(new RichPoint(new LatLng(40.22987, -3.95931)).color(Color.RED)) // Set color for some vertices
        .add(new RichPoint(new LatLng(40.23109, -3.95926)))
        .add(new RichPoint(new LatLng(40.23063, -3.95837)).color(Color.RED))
        .add(new RichPoint(new LatLng(40.23169, -3.95809)))
        .add(new RichPoint(new LatLng(40.23093, -3.95705)))
        .add(new RichPoint(new LatLng(40.23023, -3.95626)));
RichPolyline polyline = polylineOpts.build();
polyline.add(new RichPoint(new LatLng(40.23163, -3.95602)).color(Color.CYAN)); // RichPoint added after the creation of the RichPolyline
richLayer.addShape(polyline);

【讨论】:

  • 我也使用这种方法,获取所有点并从中制作折线,问题是负载太多,因为折线太多了几千
【解决方案2】:

我一直在研究一个用例,用于在 Android 的 Google Maps 上创建渐变折线,因为它不是 Google Maps Android SDK 中的内置 API。

因此,我创建了一个 Github 存储库,用于讨论用例、我采用的方法以及我如何实现它以在 Android 中的 Google 地图上显示渐变折线。

如果您对此类主题感兴趣,请查看并随时联系或贡献:)

https://github.com/ahmedadeltito/GradientPolyline

【讨论】:

    【解决方案3】:

    【讨论】:

      【解决方案4】:

      如果您正在寻找准确的绘图和跟踪,您可以给this library 一个机会

      【讨论】:

      • java.lang.NoClassDefFoundError:解析失败:Lcom/akexorcist/googledirection/GoogleDirection;在 com.rrdl.gradientpoly.GradientPoly.DrawPolyline(GradientPoly.java:115) 我有这个错误
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 2015-04-25
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多