let methodSelect, modeSelect;
url: "https://images.woosmap.com/icons/pin-red.png",
function createMarker(position, icon, map) {
const marker = new window.woosmap.map.Marker({
map = new window.woosmap.map.Map(document.getElementById("map"), {
distanceService = new woosmap.map.DistanceService();
marker = createMarker(centerLatLng, markerIcon, map);
map.addListener("click", (e) => {
marker = createMarker(e.latlng, markerIcon, map);
computeIsochrone(e.latlng);
const onChangeHandler = () => {
computeIsochrone(marker.getPosition().toJSON());
methodSelect = document.getElementById("isochrone-method-select");
modeSelect = document.getElementById("isochrone-mode-select");
distanceInput = document.getElementById("isochrone-distance-input");
methodSelect.addEventListener("change", onChangeHandler);
modeSelect.addEventListener("change", onChangeHandler);
distanceInput.addEventListener("change", onChangeHandler);
computeIsochrone(centerLatLng);
function computeIsochrone(origin) {
parseInt(distanceInput.value) > 120 ||
parseInt(distanceInput.value) <= 0
alert("Value should be between 1 and 120");
const isochroneRequest = {
method: methodSelect.value,
travelMode: modeSelect.value,
value: parseInt(distanceInput.value),
.getDistanceIsochrone(isochroneRequest)
function displayIsochrone(isochrone) {
polyline = new woosmap.map.Polyline({
path: isochrone.isoline.path || null,
fitToCoordinates(isochrone.isoline.path || null);
function fitToCoordinates(coordinates) {
const bounds = new woosmap.map.LatLngBounds();
for (const latlng of coordinates) {
window.initMap = initMap;