【发布时间】:2016-09-08 09:14:05
【问题描述】:
我正在开发一个多页面应用程序,我在检索一个页面中输入的坐标并使用它在另一个页面中显示数据时遇到了困难。我正在对输入到第一页的地址进行地理编码并将其存储在本地缓存中。
在第二页,我正在检索这些使用
var srcLat = localStorage.getItem('srcLat');
var srcLong = localStorage.getItem('srcLong');
var destLat = localStorage.getItem('destLat');
var destLong = localStorage.getItem('destLong');
我现在想找出这两个坐标之间的距离和通勤时间。有什么办法可以将srcLat和srcLong转换成一个叫src的点,可以代表这些坐标,这样我就可以用这个了-
displayRoute(srcPoint, destPoint, directionsService,
directionsDisplay);
如果有其他解决方案,请提出建议。
PS:该应用程序用于项目演示,因此只能在 chrome 上运行。因此使用本地存储。
【问题讨论】:
-
你这样做有什么问题?请提供一个 minimal reproducible example 来证明该问题。 (fiddle1 (setter), fiddle2 (getter))
标签: javascript google-maps google-maps-api-3 google-maps-markers