How many kilometers from Moscow to Korolev? Yandex.maps api

We found a car very quickly, the next day we needed transportation in the Moscow region, the tariff turned out to be slightly lower than planned, which is good news. The car was delivered on time, the forwarder completed the work on time, in accordance with the task, everything went smoothly. I will definitely use the services again!

I needed to take a large wardrobe from an apartment to another apartment. There were no assistants, I turned to Gruz-transport. I ordered a car and two movers. We arrived a little late, about 15 minutes. Everything was loaded very quickly, the price was discussed with the manager over the phone. She said if we meet the deadline, the price will not change. And so it happened, we made it and got there quickly enough.

Maksim

Used the services of the transport company Gruz-Transport for delivery household appliances, refrigerator and dishwasher. I called the operator, left a request for delivery on Sunday at 12.00 and ordered two loaders. The car arrived with a 10-minute delay due to traffic jams, but the operator warned us by phone.

The movers carefully and quickly unloaded it and brought it into the apartment on the 9th floor, hard-working guys. I was pleased with the quality of service.

Alyona

I often need to transport something and I use the services of the company Cargo Transport, it has been on the market for a long time, great experience cargo transportation, and the price is lower than others, there are often promotions. It was necessary to transport this time kitchen set and a closet. I ordered a car for the weekend and two movers, they arrived without delay, quickly unloaded everything and brought it into the apartment, thank you guys very much for the quality work, all the best.

Vladimir

I ordered a car to transport an old sofa to the country house. I ordered a car for 4 hours with movers. But we did it in three! To be honest, I thought they would spend a long time fiddling around to save time and money, but it turned out to be the opposite. The sofa was delivered safe and sound and arrived without any obstacles on the road.

Therefore, I was very pleased with the work of the employees of the Gruz-Transport company.

I’ve never used such services before, sometimes my brother helped with the move, sometimes we got by with a small car. Well, now, unfortunately, there is no one to help, and when my husband and I were already preparing to move into our apartment, I found the Gruz-Transport company to help. Hooked good price and they go to the region and not much comes out.

I thought I would have to overpay, but it turned out as they told me on the phone.

I bought furniture at Ikea, they gave me everything in disassembled boxes, and I’m a girl, in these assembly work I don’t understand anything, I can’t load and unload the furniture myself. I called the cargo taxi Gruz-Transport to help, I heard they have a jack of all trades. They responded to my call immediately and sent the car with loaders. The efficient guys arrived, loaded everything, delivered it, lifted it into the apartment and assembled all the furniture for me. Well done, what more can I say.

Svetlana

We had an addition to our family. Found new apartment, this company helped us with our move. There were no difficulties, all things were transported carefully, nothing was damaged or broken. THANK YOU!!!

Andrew Vladimirovich

I bought it last month new furniture for the living room: wardrobe, sofa, chairs. All this had to be delivered and collected. Contacted transport company"Cargo transport". I talked with the operator and agreed on delivery. The car arrived on time, there was no wait. The movers turned out to be adequate. They delivered promptly, the furniture was lifted to the third floor very carefully.

They also assembled quite quickly.

Melekhova Svetlana

17.04.2014


I think that residents of the Moscow region often faced a situation when courier delivery They separately ask for money for each kilometer from the Moscow Ring Road. Recently the task arose to at least slightly automate the calculation of the distance “from the Moscow Ring Road” to a specified point. And not in a straight line, but along the route of the car. On the roads, that is.

Thanks to the wide range of possibilities Yandex.maps API it's quite easy to do.

So, the task. Show the map, allow the user to click on any place on the map, calculate the distance from the Moscow Ring Road to this point.
the main problem here - find the nearest point of the Moscow Ring Road. This can be automated fairly approximately, but we don’t need accuracy up to a meter.

Today: drawing a Yandex.map; learning to draw polygons and marks on it; we look for the nearest points from the list of objects; We make a route and calculate the distance between two points.

Algorithm
1. You need to understand what the Moscow Ring Road is.
2. By clicking, we determine the closest point of the Moscow Ring Road to the clicked address.
3. We create a route between these two points
4. We ask the length of this route.

What is MKAD
The solution in the Sandbox makes us understand that, according to Yandex’s definition, the Moscow Ring Road is a polygon figure compiled from coordinate points. I didn’t want to mess with unnecessary json, so the array of coordinates was simply placed in a separate mkad_coords variable at the beginning of the file.
We build a polygon using these coordinates.

We get a rendered Moscow Ring Road!

We are looking for the nearest point of the Moscow Ring Road
When a click event occurs on the map, we draw a marker at this location. We don’t need it for calculations, but we do it for people =)

We are trying to find the nearest point. We smoke documentation. We understand that a polygon is one big point, and we will not be able to find the closest one among the coordinates of the polygon.
We return to the first step, instead of a polygon we add a cloud of marks, among which we will search. We make them invisible, and on top of this disgrace we draw a polygon for beauty.

This is what happens if you make all labels visible. But you shouldn’t do this, it leads to big delays due to the number of objects. =)

Now you can find the nearest point on the Moscow Ring Road.

Route
Now we have two points - where we clicked and the nearest point on the Moscow Ring Road. We ask Yandex to create a route for us, along which we will determine the distance.

This method is, of course, very approximate. The nearest point of the Moscow Ring Road is not necessarily the exit point. This can be seen if you poke on the map while route rendering is turned on.