V
V
Vadim Guk2015-01-27 02:57:04
Google
Vadim Guk, 2015-01-27 02:57:04

How can I find the closest marker to my geolocation location in Google Maps?

I found this code jsfiddle.net/wwPc6 and it almost meets all the requirements.
The idea is to show the person where the nearest warehouse with my goods is.
This script searches in all institutions of the countries, but I need it purely by my markers, but I don’t understand how to put them ... I studied the Google API for several days, but still didn’t understand how to do it in this script so that when a person clicked on the button tracked the nearest warehouse, that is, my marker ...
Can anyone help in solving this problem?
The code is jsfiddle.net/wwPc6 , only you need to literally tweak it a little, who knows the Google map API...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Guk, 2015-01-27
@Stiflerus

I forgot to write that I took this code from this page.
stackoverflow.com/questions/21634343/find-nearest-...

S
Sergeyj, 2015-01-27
@sayber

You need to cycle from the starting coordinates to drive all the others.
Find the nearest one.
This is a task from the category - Traveling salesman
The starting point of the route A1 (x1,y1) and the number of points of the route N are known.
1. Determine the distances Ri between the initial exact point and each of the points of the route using the formula:
2. The point for which the distance Ri is minimal is the next point of the route.
Actually, there was a similar question
on Google maps - how to build a logical, short route?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question