Help, please, on the Yandex map, display the route by segments (not taking into account roads, borders). Those. there is an array of points and you need to connect them with segments.
Closed due to the fact that the essence of the issue is incomprehensible by the participants Enikeyschik , AK β¦ , 0xdb , aleksandr barakin , freim Jan 25 at 8:02 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- I put a title in the search and gave me a solution. Minus for the lack of attempts to solve the problem. - Enikeyschik
|
1 answer
The Maps API has a tool for drawing broken lines. Sandbox example
ymaps.ready(init); function init() { // Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠ°ΡΡΡ. var myMap = new ymaps.Map("map", { center: [55.72, 37.44], zoom: 10 }, { searchControlProvider: 'yandex#search' }); // Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π»ΠΎΠΌΠ°Π½ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Π²ΡΠΏΠΎΠΌΠΎΠ³Π°ΡΠ΅Π»ΡΠ½ΠΎΠ³ΠΎ ΠΊΠ»Π°ΡΡΠ° Polyline. var myPolyline = new ymaps.Polyline([ // Π£ΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ Π²Π΅ΡΡΠΈΠ½ Π»ΠΎΠΌΠ°Π½ΠΎΠΉ. [55.80, 37.50], [55.80, 37.40], [55.70, 37.50], [55.70, 37.40] ], { // ΠΠΏΠΈΡΡΠ²Π°Π΅ΠΌ ΡΠ²ΠΎΠΉΡΡΠ²Π° Π³Π΅ΠΎΠΎΠ±ΡΠ΅ΠΊΡΠ°. // Π‘ΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π±Π°Π»ΡΠ½Π°. balloonContent: "ΠΠΎΠΌΠ°Π½Π°Ρ Π»ΠΈΠ½ΠΈΡ" }, { // ΠΠ°Π΄Π°Π΅ΠΌ ΠΎΠΏΡΠΈΠΈ Π³Π΅ΠΎΠΎΠ±ΡΠ΅ΠΊΡΠ°. // ΠΡΠΊΠ»ΡΡΠ°Π΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΡ Π·Π°ΠΊΡΡΡΠΈΡ Π±Π°Π»ΡΠ½Π°. balloonCloseButton: false, // Π¦Π²Π΅Ρ Π»ΠΈΠ½ΠΈΠΈ. strokeColor: "#000000", // Π¨ΠΈΡΠΈΠ½Π° Π»ΠΈΠ½ΠΈΠΈ. strokeWidth: 4, // ΠΠΎΡΡΡΠΈΡΠΈΠ΅Π½Ρ ΠΏΡΠΎΠ·ΡΠ°ΡΠ½ΠΎΡΡΠΈ. strokeOpacity: 0.5 }); // ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π»ΠΈΠ½ΠΈΡ Π½Π° ΠΊΠ°ΡΡΡ. myMap.geoObjects.add(myPolyline); } <!DOCTYPE html> <html> <head> <title>ΠΠΎΠΌΠ°Π½Π°Ρ</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <script src="polyline.js" type="text/javascript"></script> <style> html, body, #map { width: 100%; height: 100%; padding: 0; margin: 0; } </style> </head> <body> <div id="map"></div> </body> </html> |