开发者

Getting MULTIPLE distances with google maps

So.. I have 10 latitude/longitude values in a database.

Using the V3 JS API i plot these on a map.

I then have an 11th point which is 'users current location'

I want to find the distance between the user location and each of the other points.

I have created a javascript which does this - essentially, it gets the lat/long, plots the markers etc. Then with a PHP foreach loop, i loop through the lat/long pairs, and output the javascript which gets these values.

Now.. I myself do not really understand how this works.. i followed tutorials :) But it does. It uses the directionservices() function. None the less, I feel that it is safe to assume that this method must be 开发者_JAVA技巧somewhat inefficient.

Does anyone know if this is a good approach?efficient approach? what alternatives there arE?

Many Thanks


In which database do you store the lat lng values? If your database is spatially enabled as PostGis is you can use build in database functions that i think is fast and efficient.

Then maybe you can find also a way for cashing precalculated numbers(i.e. distances) and improve the speed additionally.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜