How to generate coordinates in between two known points

前端 未结 3 1951
攒了一身酷
攒了一身酷 2021-01-05 08:15

Background:

I\'m working with transport routes and Google provides Route points far apart enough to create \'shapes\'. These are the bus/train route

3条回答
  •  半阙折子戏
    2021-01-05 08:20

    The following solution isn't exactly what you've requested, but may suffice for your purposes...

    Check the official docs (https://developers.google.com/maps/documentation/javascript/reference) for the interpolate method. From the docs: 'Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.'

    So if you know that your original points are, say, 100m apart, and you specify 0.05 as the fraction, the method will return the lat/lng along that line for every 5m.

提交回复
热议问题