Malwinder Singh
Malwinder Singh

Reputation: 7040

How to customise polyline to look like Google Maps Android application?

On adding Polyline, following is shown: enter image description here

How o show the following?

enter image description here

Difference is in Border of polyline

Upvotes: 0

Views: 1371

Answers (1)

user2711811
user2711811

Reputation:

(Just search on 'polyline border' (in SO) and find numerous similar solutions - but I couldn't help trying it myself.)

For a border draw two PolyLines with varying width and color:

    PolylineOptions po = new PolylineOptions().add(latLng)
            .add(new LatLng(latLng.latitude+.05,latLng.longitude))
            .add(new LatLng(latLng.latitude+.07,latLng.longitude+.01))
            .add(new LatLng( latLng.latitude+.09, latLng.longitude+.02))
            .add(new LatLng(latLng.latitude+.09, latLng.longitude+.03));
    po.color(Color.BLACK).width(16);
    Polyline polyline = mMap.addPolyline(po);
    po.color(Color.CYAN).width(10);
    polyline = mMap.addPolyline(po);

Results in:

enter image description here

Upvotes: 2

Related Questions