The site has Yandex.Maps with the route created through the API. It is necessary to print it.
What is the best way to do? I myself think of doing, having received a picture through the static Yandex.Maps API, but I just canβt get the vertices of the broken line from the map.
The code is very dirty, but working:
<a id="map-img" class="btn btn-success">ΠΠ° ΠΏΠ΅ΡΠ°ΡΡ</a> <script> window.onload = function() { $('#map-img').on('click', function(e) { e.preventDefault(); // var win = window.open(); // win.document.write("<img src='"+$(this).attr('href')+"'>"); // console.log("<img src='"+$(this).attr('href')+"'>"); window.print(); }); }; </script> <div id="map" style="width: 1000px; height: 1000px"></div> <script src="https://api-maps.yandex.ru/2.0-stable/?load=package.full&lang=ru-RU&coordorder=longlat" type="text/javascript"></script> <script type="text/javascript"> ymaps.ready(init); var myMap; var cleaner_addr = "<?php echo('ΠΠΎΡΠΊΠ²Π°, ΠΠ°Π³Π°ΡΠΈΠ½ΡΠΊΠ°Ρ ΡΠ»., 1c23');?>"; var client_addr = "<?php echo('ΠΠΎΡΠΊΠ²Π°, ΡΠ». ΠΡΠ²Π° Π’ΠΎΠ»ΡΡΠΎΠ³ΠΎ, 16');?>"; function init() { cleaner_geocode = ymaps.geocode(cleaner_addr, { "json": true }); cleaner_geocode.then( function(res) { var cleaner_coords = res.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData.Point.coordinates; console.log(cleaner_coords); myMap = new ymaps.Map("map", { center: cleaner_coords, zoom: 12 }); myMap.controls.add( new ymaps.control.ZoomControl() ); var cleanerPM = new ymaps.Placemark(cleaner_coords, { hintContent: '1', balloonContent: 'Π‘ΡΠΎΠ»ΠΈΡΠ° Π ΠΎΡΡΠΈΠΈ' }); myMap.geoObjects.add(cleanerPM); var metro_geocode = ymaps.geocode(cleaner_coords, { "json": true, "kind": "metro", "multiRoute": true, "routingMode": "masstransit" }); metro_geocode.then( function(res) { metro_coords = res.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData.Point.coordinates; console.log(cleaner_coords); var client_geocode = ymaps.geocode(client_addr, { "json": true }); client_geocode.then( function(res) { client_coords = res.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData.Point.coordinates; ymaps.route([ cleaner_coords, metro_coords, client_coords ]).then( function(route) { myMap.geoObjects.add(route); console.log(route.getPaths().geometry); var coords = cleaner_coords.join(',') + ',' + metro_coords.join(',') + ',' + client_coords.join(','); $('#map-img').attr('href', 'https://static-maps.yandex.ru/1.x/?l=map&pl=' + coords); }, function(error) { alert("ΠΠΎΠ·Π½ΠΈΠΊΠ»Π° ΠΎΡΠΈΠ±ΠΊΠ°: " + error.message); } ); }, function(err) { // ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΎΡΠΈΠ±ΠΊΠΈ } ); }, function(err) { // ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΎΡΠΈΠ±ΠΊΠΈ } ); }, function(err) { // ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΎΡΠΈΠ±ΠΊΠΈ } ); } </script>
do().then(function() { do().then(); }or build a chain of promises or execute queries in parallel (in this case it is justified) - tutankhamun