如何将当前位置传递给 EJS 模板

How to pass the Current Position to the EJS template

我正在使用 EJS,并且有一个 link 到 google 的地图,我需要在其中获取起点的当前用户位置,并从数据库中获取目的地。我不知道如何将这个原始变量传递给 link。我尝试了下面的方法,但是当然,服务器端的用户位置不可用。关于如何将位置动态传递给 link 的任何线索?

<a href='https://www.google.com/maps/dir/?api=1
&origin=
<%=userLatitude%>,
<%=userLongitude%>
&destination=
<%=destination.latitude%>, 
<%=destination.longitude%>
&travelmode=driving'
target="_blank">Ir </a>

通过简单地在渲染后用 JS 编辑 link 找到了解决方案。