heremaps / here-android-sdk-examples

Java-based projects using the HERE SDK for Android.
Apache License 2.0
145 stars 191 forks source link

Problem map polyline custom pattern #367

Closed edurocks closed 4 years ago

edurocks commented 4 years ago

Good Afternoon, I have a problem. I am trying to draw a route on the map but with a dashed line. Whem I use the dah pattern from the map polyline it doesn´t give the effect that i want so i thought to use a image to do it and use the setCustomPattern to do it but when I provide a png image it doesn´t show the path with this image. I don´t know what is going on and if I am using it correctly. Thanks for the support.

Merlin1stHere commented 4 years ago

@edurocks Could you provide a sample for us? You can use our map-objects example and modify it to show the problem.

edurocks commented 4 years ago

Hi @Merlin1stHere . I am trying to do something like this. But the polyline never show the image. I don´t know if this image has to be on a specific format or not but i didn´t understand how to use it.

` List mRoutePathCoordinates = new ArrayList<>(); GeoPolyline mPolylineSecondRoute = new GeoPolyline(); mMapPolylineSecondRoute = new MapPolyline();

    mMapPolylineSecondRoute.setPatternStyle(MapPolyline.PatternStyle.DASH_PATTERN);
    Image image = new Image();
    try {
        image.setImageResource(R.drawable.parking_active);
    } catch (IOException e) {
        e.printStackTrace();
    }
    mMapPolylineSecondRoute.setCustomPattern(image);
    mMapPolylineSecondRoute.setDepthTestEnabled(true);
    mMapPolylineSecondRoute.setExtrusionEnabled(true);
    mMapPolylineSecondRoute.setPerspectiveEnabled(true);
    mMapPolylineSecondRoute.setLineWidth(6);
    mMapPolylineSecondRoute.setZIndex(1);

    for (GeoCoordinate geoCoordinate : routeGeometry) {
        mRoutePathCoordinates.add(new GeoCoordinate(geoCoordinate.getLatitude(), geoCoordinate.getLongitude()));
    }

    mPolylineSecondRoute.add(mRoutePathCoordinates);
    mMapPolylineSecondRoute.setGeoPolyline(mPolylineSecondRoute);

    if (mMap != null) mMap.addMapObject(mMapPolylineSecondRoute);`
Merlin1stHere commented 4 years ago

@edurocks Could you provide a compilable sample for us? It would be better if I could see the image and the exact source code.

edurocks commented 4 years ago

Solved. I used the properties of the polyline and I achieve my result. Now my problem is with the marker cluster. They are not appearing on the map. ClusterLayer mClusterLayer = new ClusterLayer(); BasicClusterStyle mBasicClusterStyle = new BasicClusterStyle(); mBasicClusterStyle.setFillColor(ContextCompat.getColor(mMainActivity, R.color.routePath)); ClusterTheme clusterTheme = new ClusterTheme(); clusterTheme.setStyleForDensityRange(2, 300, mBasicClusterStyle); mClusterLayer.setTheme(clusterTheme); mMap.addClusterLayer(mClusterLayer); mClusterLayer.addMarkers(mTriggersMarker);