Search code examples
javascripthtmlnode.jsejstemplate-engine

How to pass the Current Position to the EJS template


I'm using EJS and there's a link to google maps where I'd need to get the current user position for the origin and the destination is gotten from the database. I can't figure out how to pass this origin variable to the link. I tried the below, but of course, the user location is not available on the server-side. Any clue on how to pass the position to the link dynamically?

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


Solution

  • Found the solution by simply editing the link with JS after rendering.