Skip to content

Commit

Permalink
feat: Add arrow symbol to polyline
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedhossamdev committed Aug 23, 2024
1 parent a364a89 commit af6561f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/lib/googleMaps.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { COLORS } from '$lib/colors';

/**
* Loads the Google Maps JavaScript library.
* @param {string} apiKey - The API key for accessing the Google Maps API.
Expand Down Expand Up @@ -154,10 +156,33 @@ export async function createPolyline(shape) {
const polyline = new window.google.maps.Polyline({
path,
geodesic: true,
strokeColor: '#00FF00',
strokeColor: COLORS.POLYLINE,
strokeOpacity: 1.0,
strokeWeight: 4
});

return polyline;
}

/**
* Adds an arrow to the polyline.
* @param {google.maps.Polyline} polyline - The polyline to which the arrow will be added.
*/
export function addArrowToPolyline(polyline) {
const arrowSymbol = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
scale: 2,
strokeColor: COLORS.POLYLINE_ARROW,
strokeWeight: 3
};

polyline.setOptions({
icons: [
{
icon: arrowSymbol,
offset: '100%',
repeat: '50px'
}
]
});
}

0 comments on commit af6561f

Please sign in to comment.