nativescript-google-maps-sdk
nativescript-google-maps-sdk copied to clipboard
Dashed polyline
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!
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 ?
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 small correction:
instead of GMSLengthKind.rhumb
must be GMSLengthKind.kGMSLengthRhumb
@Stanteq Thanks for the correction. Edited.