Planowanie trasy – mapa dojazdu • Jak dojade do celu? • Trasa.info

[] Planowanie trasy – mapa dojazdu • Jak dojade do celu? • Trasa.info Na stronie używamy cookies. Korzystanie z witryny oznacza zgodę na ich wykorzystywanie. Szczegóły znajdziesz w Polityce Prywatności. 750) { document.write(’]]>’); } ’+e+’km/h – '+hours+’ h '+minutes+’ min’); }) routeIndex = parseInt($(this).attr(’feature_index’)); $(this).parent().children().removeClass(’active’); $(this).addClass(’active’); if (tomtom_map) { redrawTomTomRoutes(geojson, routeIndex); } }); $(document).on(’mouseover’, ’.tabela_tras .osm.alternative-route’, function(evt) { }); $(document).on(’mouseout’, '#alternatives span’, function(evt) { }); if (typeof(infoBoxInit) == 'function’) { infoBoxInit(); } $(document).on(„change”, 'input[type=”text”]’, function(){ if(document.getElementById(’DirectionDistance’) != null){ caclCost(document.getElementById(’DirectionDistance’).value); } }); $(document).on(„click”, '#journey-costs input[type=”submit”]’, function(ev){ ev.stopPropagation(); ev.preventDefault(); caclCost(document.getElementById(’DirectionDistance’).value); }); $(’#MapHomeForm’).on(’submit’, function (ev) { ev.stopPropagation(); ev.preventDefault(); searchGeo($(’#MapSearchMap’).val()); }); $(’.poi’).on(’change’, 'input’, function(event) { event.preventDefault(); $(this).find(’.points’).removeClass(’active’); show_markers($(this).val(), this.checked); if (this.checked) { $(this).closest(’.points’).addClass( „active” ); } }); if (typeof(is_post) != „undefined” && is_post) { for (var i = 0; i < coords.length; i++) { markers[i] = []; $('.poi').append(' '+coords[i][0]+''); } } $('form .tc .adv').on('click', function (ev) { $('#searchForm .more').show(); $(this).hide(); }); if ($('#DirectionDriveFrom').val() != '' && $('#DirectionDriveTo').val() != '') { calcRoute(); return; } if ($('#placePlace').val() != '') { searchGeo($('#placePlace').val()); return; } }); const stringifyJSON = data => { if (data === undefined) return undefined else if (data === null) return 'null’ else if (data.constructor === String) return '”’ + data.replace(/”/g, '”’) + '”’ else if (data.constructor === Number) return String(data) else if (data.constructor === Boolean) return data ? 'true’ : 'false’ else if (data.constructor === Array) return '[ ’ + data.reduce((acc, v) => { if (v === undefined) return […acc, 'null’] else return […acc, stringifyJSON(v)] }, []).join(’, ’) + ’ ]’ else if (data.constructor === Object) return '{ ’ + Object.keys(data).reduce((acc, k) => { if (data[k] === undefined) return acc else return […acc, stringifyJSON(k) + ’:’ + stringifyJSON(data[k])] }, []).join(’, ’) + ’ }’ else return '{}’ } function codeAddress(place, zoom, disable_marker) { //console.log(’codeAddress’, place); $.ajax({ url: '/search/?q=’ + encodeURIComponent(place) + '&format=json&addressdetails=1&limit=1′, success: function( place_data ) { if (place_data.length > 0) { $(’#sticky_side_links’).hide(); //console.log(’place_data’, place_data); for (var i = 0; i < markers.length; i++) { lmap.removeLayer(markers[i]) } if (typeof(disable_marker) == 'undefined' || disable_marker != 'disable') { var point = [place_data[0].lon, place_data[0].lat]; var marker = new tt.Marker({ element: createMarkerElement('waypoint') }).setLngLat(point).addTo(tomtom_map); markers.push(marker); var popup = new tt.Popup({offset: popupOffsets, className: 'popup-yellow'}).setHTML("" + place + "
Zarezerwuj hotel”); marker.setPopup(popup).togglePopup(); } if (typeof(zoom) != 'undefined’) { //console.log(’zoom’, zoom); lmap.setView([place_data[0].lat, place_data[0].lon], zoom); } else { lmap.setView([place_data[0].lat, place_data[0].lon]); } } }, error: function(xhr, status, error) { console.log(xhr.responseText); } }); } function customFormatTime(seconds) { var h = Math.floor(seconds / 3600); var m = Math.floor((seconds – h*3600)/60); //date = (new Date).clearTime().addSeconds(seconds).toString(’H g. mm’) + ’ min’; date = ” + h + ’ h ’ + m + ’ min’; return date; } function degreesToRadians(degrees) { return degrees * Math.PI / 180; } function distanceInKmBetweenEarthCoordinates(lat1, lon1, lat2, lon2) { var earthRadiusKm = 6371; var dLat = degreesToRadians(lat2-lat1); var dLon = degreesToRadians(lon2-lon1); lat1 = degreesToRadians(lat1); lat2 = degreesToRadians(lat2); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); return earthRadiusKm * c; } function in_array(arr, elem) { for (var i = 0; i < arr.length; i++) { if (arr[i] == elem) { return true; } } return false; } var indices_combinations = []; function get_cities_strings(cities_list) { // number of arrays var n = cities_list.length; // to keep track of next element in each of the n arrays var indices = []; // initialize with first element's index for (var i = 0; i < n; i++) { indices[i] = 0; } while (1) { // print current combination var result = []; for (var i = 0; i = 0 && (indices[next] + 1 >= cities_list[next].index.length)) next–; // no such array is found so no more // combinations left if (next < 0) return; // if found move to next element in that // array indices[next]++; // for all arrays to the right of this // array current index again points to // first element for (var i = next + 1; i < n; i++) indices[i] = 0; } } function addAlternatives(rt_info) { if (typeof(rt_info) == 'object') { $('#alternatives').empty(); var last_route_coords = rt_info[rt_info.length-1].route_coords; var lineLength = distanceInKmBetweenEarthCoordinates(rt_info[0].route_coords[0][0], rt_info[0].route_coords[0][1], last_route_coords[last_route_coords.length-1][0], last_route_coords[last_route_coords.length-1][1]).toFixed(2); // konstruujemy drzewo dojazdu łącząc wszystki epunkty pośrednie w 1 całościowy var cities_list = []; var i = 0; for (i = 0; i < rt_info.length; i++) { if (cities_list.length == 0 || cities_list[cities_list.length-1].city != rt_info[i].start_address) { var o = {city: rt_info[i].start_address, index: [i]} cities_list.push(o); } else if (cities_list[cities_list.length-1].city == rt_info[i].start_address) { cities_list[cities_list.length-1].index.push(i); } } //cities_list.push({city: rt_info[i-1].end_address, index: [i]}); //console.log(cities_list); indices_combinations = []; get_cities_strings(cities_list); //console.log(indices_combinations); for (var i = 0; i < indices_combinations.length; i++) { var first = indices_combinations[i][0]; var last = indices_combinations[i][indices_combinations[i].length-1]; var distance = 0; var duration = 0; var indexes_string = ''; //console.log('indices_combinations[i]',indices_combinations[i]); for (var j = 0; j < indices_combinations[i].length; j++) { var idx = indices_combinations[i][j]; indexes_string += '' + idx; if (j < indices_combinations[i].length-1) { indexes_string += ','; } distance += parseFloat(rt_info[idx].distance); duration += parseFloat(rt_info[idx].duration); //console.log('i',i,'j',j,'idx',idx,'rt_info[idx].distance',rt_info[idx].distance,'rt_info[idx].duration',rt_info[idx].duration,'first',first,'last',last,'duration',duration,'distance',distance); } $('#alternatives').append( '

  • n Trasa ’ + (i + 1) + 'n n n ’ + rt_info[first].start_address + ’ – ’ + rt_info[last].end_address + 'n Trasa ’ + (i + 1) + 'n n n Silniční vzdálenost: ’ + (parseFloat(”+distance)).toFixed(2) + ’ kmn Vzdálenost vzdušnou čarou: ’ + lineLength + ’ kmn Čas cesty: ’ + customFormatTime(duration) + 'n n n ’); } $(’#alternatives’).show(); } } function getItemFromGeoResponse(name, geoResponse) { for (var i = 0; i 0) { return geoResponse[0]; } return null; } var a_route_coords = []; var a_places = []; var endIcon = null; var startIcon = null; var startPoint, endPoint; var routes_layer = null; var routes_json = null; var start_marker = null; var end_marker = null; var start_marker_popup = null; var end_marker_popup = null; var colors = [’#00D7FF’, '#FF0000′, '#4AF046′, '#000000′, '#FF00D2′, '#FFFF00′]; function updateBounds(route_coords, viewport) { if (typeof(route_coords) == 'undefined’ || route_coords.length < 2) { return; } var len = route_coords.length; bounds = new tt.LngLatBounds(); bounds.extend(tt.LngLat.convert([route_coords[0].lon, route_coords[0].lat])); bounds.extend(tt.LngLat.convert([route_coords[len-1].lon, route_coords[len-1].lat])); if (viewport) { bounds.extend(tt.LngLat.convert(viewport.topLeftPoint)); bounds.extend(tt.LngLat.convert(viewport.btmRightPoint)); } if (!bounds.isEmpty()) { tomtom_map.fitBounds(bounds, { duration: 0, padding: 50 }); } }; function updateRoutesBounds(coordinates) { bounds = new tt.LngLatBounds(); coordinates.forEach(function(point) { bounds.extend(tt.LngLat.convert(point)); }); if (!bounds.isEmpty()) { tomtom_map.fitBounds(bounds, { duration: 0, padding: 50 }); } }; function createMarkerElement(type) { var element = document.createElement('div'); element.className = 'supporting-marker'; var innerElement = document.createElement('div'); innerElement.className = type !== 'supporting' ? 'tt-icon -white -' + type : 'supporting-circle'; element.appendChild(innerElement); return element; } function addRouteMarkers(feature) { if (start_marker) { start_marker.remove(); start_marker = null; } if (end_marker) { end_marker.remove(); end_marker = null; } var startPoint, endPoint; if (feature.geometry.type === 'MultiLineString') { startPoint = feature.geometry.coordinates[0][0]; //get first point from first line endPoint = feature.geometry.coordinates.slice(-1)[0].slice(-1)[0]; //get last point from last line } else { startPoint = feature.geometry.coordinates[0]; endPoint = feature.geometry.coordinates.slice(-1)[0]; } var place_start = a_places[0]; var place_end = a_places[1]; start_marker = new tt.Marker({ element: createMarkerElement('start') }).setLngLat(startPoint).addTo(tomtom_map); end_marker = new tt.Marker({ element: createMarkerElement('finish') }).setLngLat(endPoint).addTo(tomtom_map); var popup = new tt.Popup({offset: popupOffsets, className: 'popup-yellow'}).setHTML("" + place_start + "
    Zarezerwuj hotel”); start_marker.setPopup(popup).togglePopup(); var popup = new tt.Popup({offset: popupOffsets, className: 'popup-green’}).setHTML(„” + place_end + „
    Zarezerwuj hotel”); end_marker.setPopup(popup).togglePopup(); } function clearMap() { if (tomtom_map.getLayer(’route’)) { tomtom_map.removeLayer(’route’); tomtom_map.removeSource(’route’); } } function remove_route_layers() { for(var i = 0; i < 3; i++) { if (tomtom_map.getLayer('route' + i)) { tomtom_map.removeLayer('route' + i); tomtom_map.removeSource('route' + i); } } } function get_route_layer(index, geometry, color, line_width) { return { 'id': 'route' + index, 'type': 'line', 'source': { 'type': 'geojson', 'data': {'type': 'Feature', 'geometry': geometry} }, 'paint': { 'line-color': color, 'line-width': line_width } } } function redrawTomTomRoutes(geojson, routeIndex) { remove_route_layers(); for (var index = 0; index < geojson.features.length; index++) { var line_width = (index == routeIndex) ? 6 : 3; var line_color = (index == routeIndex) ? colors[1] : colors[0]; tomtom_map.addLayer(get_route_layer(index, geojson.features[index].geometry, line_color, line_width)); } } function drawTomTomRoute(route_coords, locations_string, routeIndex) { if (typeof(routeIndex) == 'undefined' || routeIndex 2) { routeIndex = 0; } //console.log('route_coords', route_coords); var locations = ''; if (typeof(locations_string) != 'undefined') { locations = locations_string; } else { for (var i = 0; i < route_coords.length; i++) { if (locations != '') { locations += ':'; } locations += route_coords[i].lon + ',' + route_coords[i].lat; } } clearTomTomMap(); remove_route_layers(); var colorIndex = 0; var is_mobile = 0; //console.log('locations:', locations); //locations = '20.090542,49.880343:19.936856,50.061947'; tt.services.calculateRoute({key: tomtom_key, traffic: false, locations: locations, maxAlternatives: 2}) .then(function(response) { geojson = response.toGeoJson(); console.log('geojson', geojson); redrawTomTomRoutes(geojson, routeIndex); var bounds = new tt.LngLatBounds(); geojson.features[routeIndex].geometry.coordinates.forEach(function(point) { try { bounds.extend(tt.LngLat.convert(point)); } catch (e) { for (var k = 0; k < point.length; k++) { bounds.extend(tt.LngLat.convert(point[k])); } } }); tomtom_map.fitBounds(bounds, { duration: 0, padding: 50 }); addRouteMarkers(geojson.features[routeIndex]); $('#alternatives').empty(); //console.log('results_count', results_count); for (var i = 0; i < geojson.features.length; i++) { var current_feature = geojson.features[i]; //console.log('i', i, 'current_feature', current_feature); $('.pathInfo').show(); if (i == routeIndex) { $('#speed-cases').empty(); var a_distance = (parseFloat(''+(current_feature.properties.summary.lengthInMeters/1000))).toFixed(2); $('#DirectionDistance').val(a_distance); //$('.aDistanceL').text(lineLength); $('.aTime').text(customFormatTime(current_feature.properties.summary.travelTimeInSeconds)); $('.pathInfo .totalDistance').html(a_distance); $('.pathInfo .lineDistance').html(''); var speeds=[40,60,80,100,120,140]; $.each(speeds,function(i,e){ var hours = a_distance / e; hours = parseInt(''+hours); var minutes = (a_distance/e-parseInt(''+(a_distance/e)))*60; minutes = parseInt(''+minutes); $('#speed-cases').append('
  • ’+e+’km/h – '+hours+’ h '+minutes+’ min’); if (i == 1) { $(’.pathInfo .totalDuration’).html(hours+’ h '+minutes+’ min’); } }); } $(’#alternatives’).append(” + ” + (i+1) + ’]]>
  • ’ + ’

    ’ + ” + a_places[0] + ’ – ’ + a_places[a_places.length-1] + ” + 'Odległość drogowa: ’ + (parseFloat(”+(current_feature.properties.summary.lengthInMeters/1000))).toFixed(2) + ’ km’ + 'Czas przejazdu: ’ + customFormatTime(current_feature.properties.summary.travelTimeInSeconds) + ” + ’

    ’ + ”); } }); } function initializeTomTomMap(zoom) { $(’#leaflet_map’).show(); $(’#google_map’).hide(); if (typeof(zoom) == 'undefined’ || !zoom) { zoom = 8; } if (!tomtom_map) { var center_coordinates = [current_lonlat[0], current_lonlat[1]]; tomtom_map = tt.map({ key: tomtom_key, container: 'leaflet_map’, center: center_coordinates, zoom: zoom }); } } function calcTomTomRoute(start, end, waypts) { $(’#leaflet_map’).show(); $(’#map-canvas’).hide(); $(’#sticky_side_links’).hide(); if (typeof(zoom) == 'undefined’ || !zoom) { zoom = 8; } a_route_coords = []; a_places = []; if (!tomtom_map) { initializeTomTomMap(zoom); } if (tomtom_map) { var i = 0; var options = { limit: 1, unwrapBbox: true //language: 'pl-PL’ } a_places.push(start); for (i = 0; i 0 && geoResponses[0].position) { a_route_coords[parseInt(”+result.counter)] = geoResponses[0].position; $.ajax({type: „GET”, url: '/savelocation.php’, data: {address: options.query, lat: geoResponses[0].position.lat, lng: geoResponses[0].position.lon}, success: function(result) {} }); draw = true; for (k = 0; k iframe#google_map_embed’).attr(’src’, 'https://www.google.com/maps/embed/v1/place?q=’ + place + '&key=’ + google_key + '&language=pl’); }

    Wyznaczanie trasy

    Przewodnik

    Więcej popularnych miast:

    Więcej popularnych krajów:

    max_height){ $(’.extra-info #more’).css(’display’, 'inline-block’); $(’.extra-info’).css({„max-height”: max_height+”px”, „overflow”: „hidden”}); $(’.extra-info’).on(’click’, '#more span’, function(event) { event.preventDefault(); $(’.extra-info #more’).css(’display’, 'none’); $(’.extra-info’).css({„max-height”: „none”, „overflow”: „visible”}); }); } } ]]> 0) ? window.innerWidth : screen.width; if(deviceWidth 0) ? window.innerWidth : screen.width; if(deviceWidth 400) return; if(document.getElementById(„sticky_bottom_links”) == null){ var elem = document.createElement(’div’); elem.id = „sticky_bottom_links”; elem.style.cssText = 'position:fixed;width:100%;height:70px;z-index:100;bottom:0;font-family: Arial; font-weight:bold; font-size: 12px;’; document.body.appendChild(elem); document.body.style.paddingBottom = ’70px’; } if(inside){ var main = document.getElementById(„sticky_bottom_links”); main.innerHTML = main.innerHTML + inside; } } function stickySide(url){ var deviceWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width; var contentWidth = document.getElementById(’footer’).offsetWidth; //if(((deviceWidth-contentWidth)/2) < 270) return; //if(deviceWidth < 900) return; if(document.getElementById("sticky_side_links") == null){ var elem = document.createElement('div'); elem.id = "sticky_side_links"; //elem.style.cssText = 'position:fixed;width:280px;height:100px;z-index:100;right:0;top:50%;margin-top:-50px;'; //document.body.appendChild(elem); elem.style.cssText = 'position:absolute;width:280px;height:46px;z-index:100;left:8px;bottom:30px;margin-top:-50px;'; document.getElementById('map').appendChild(elem); var link1 = document.createElement('a'); link1.href = url; link1.rel = "nofollow"; link1.target = "_blank"; link1.style.cssText = "display:block; text-decoration: none;font-family: Arial; font-weight:bold; font-size: 16px;line-height:16px; color: #000;background-color: #eebd28; border-radius: 10px;position: relative;padding: 15px 10px 15px 60px;"; link1.innerHTML='ZAREZERWUJ NOCLEG »'; elem.appendChild(link1); /* var link2 = document.createElement('a'); //link2.href = "https://www.rentalcars.com/pl/?cor=pl&affiliateCode=trasainfo"; link2.href = "https://www.comperialead.pl/a/pp_adserwer.php?link=5430a96abb7c4fb58b9cb35fc73308f4"; link2.rel = "nofollow, noindex"; link2.target = "_blank"; link2.style.cssText = "margin-top: 8px;display:block; text-decoration: none;font-family: Arial; font-weight:bold; font-size: 16px;line-height:16px; color: #fff;background-color: #63a16b; border-radius: 10px;position: relative;padding: 15px 10px 15px 60px;"; link2.innerHTML='Tanie OC - sprawdź ofertę »'; elem.appendChild(link2);*/ if(deviceWidth < 900){ //elem.style.cssText = 'position:absolute;width:270px;height:75px;z-index:100;left:8px;bottom:25px;'; elem.style.cssText = 'position:absolute;width:270px;height:33px;z-index:100;left:8px;bottom:25px;'; link1.style.fontSize = "13px"; link1.style.lineHeight = '13px'; link1.style.borderRadius = '8px'; link1.style.padding = "10px 10px 10px 50px"; link1.firstChild.style.backgroundSize='70%'; link1.firstChild.style.padding = "0 20px"; /* link2.style.fontSize = "13px"; link2.style.lineHeight = '13px'; link2.style.borderRadius = '8px'; link2.style.padding = "10px 10px 10px 50px"; link2.firstChild.style.backgroundSize='70%'; link2.firstChild.style.padding = "0 20px";*/ } } } function infoBoxInit(){ var link = 'https://www.booking.com/index.pl.html?aid=1484610'; var background = '#29a56a'; var color = '#fff'; var boxText = document.createElement("div"); boxText.id = "main-infobox"; boxText.style.cssText = "display:block; position: absolute; top: 50%; left: 10px; text-decoration: none;font-family: Arial; font-weight:bold; font-size: 12px; color: #000; border: 1px solid "+background+"; border-radius: 10px; box-shadow: 5px 5px 10px grey; background: "+background+";"; boxText.innerHTML = 'x'+ 'Zarezerwuj Nocleg »’; //document.getElementById(’google_map’).appendChild(boxText); //document.getElementById(„close-info-window”).onclick = function(){ // document.getElementById(’main-infobox’).style.display=’none’; //}; //stickyBottom(’Zarezerwuj Nocleg »’); stickySide(link); } function codeAddress_OLD() { var address = document.getElementById(’MapsTagSearchMap’).value; geocoder.geocode( { 'address’: address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { infoBoxInitClose(); map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); infoBox( address, results[0].geometry.location, 'end’, 100); } }); } ]]>

    Source

    Opublikowano
    Umieszczono w kategoriach: Turystyka

    Dodaj komentarz

    Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *