nativescript-google-maps-sdk icon indicating copy to clipboard operation
nativescript-google-maps-sdk copied to clipboard

Dashed polyline

Open FranciZ opened this issue 6 years ago • 4 comments

Hi,

is there simple way to style the Polyline? There's a way now to add a pattern to the Polyline as per Google. Is this possible with the SDK as is, or does this need implementation?

Thanks!

FranciZ avatar May 20 '18 10:05 FranciZ

I would like to know too.

I also miss the other Polylines options. https://developers.google.com/maps/documentation/javascript/reference/3/polygon#PolylineOptions

Can someone help me by pointing the way for me to implement other options?

@dapriett ?

thiagotalma avatar Jul 30 '18 02:07 thiagotalma

For anyone looking for this in the future below is an example for how to add caps and create dashed lines for Android and iOS. I don't think there's a way to do dotted lines on iOS using spans unfortunately.

if (isAndroid) {
        const pattern = java.util.Arrays.asList([new com.google.android.gms.maps.model.Dot(), new com.google.android.gms.maps.model.Gap(6)]);
        polyline.android.pattern(pattern);
        polyline.android.jointType(com.google.android.gms.maps.model.JointType.ROUND);
        polyline.android.startCap(new com.google.android.gms.maps.model.RoundCap());
        polyline.android.endCap(new com.google.android.gms.maps.model.RoundCap());
} else if(isIOS) {
        const styles = [GMSStrokeStyle.solidColor(UIColor.whiteColor), GMSStrokeStyle.solidColor(UIColor.clearColor)];
        const lengths = [15, 10];
        polyline.ios.spans = GMSStyleSpans(polyline.ios.path, styles, lengths, GMSLengthKind.kGMSLengthRhumb);
}

FranciZ avatar Mar 03 '20 12:03 FranciZ

@FranciZ small correction:

instead of GMSLengthKind.rhumb must be GMSLengthKind.kGMSLengthRhumb

standevo avatar Jun 11 '20 22:06 standevo

@Stanteq Thanks for the correction. Edited.

FranciZ avatar Jun 14 '20 04:06 FranciZ