html - 在 HTML 中,如何将变量附加到 url?
问题描述
我在表格中有一个地址列表,我想要它,这样如果你点击地址,你会得到一个指向那个地方的谷歌地图链接。这是我的尝试;<a ...> 是我尝试得到它但最终失败了。如果 (40,-70) 是纬度/经度,我想要一个示例谷歌地图页面将您带到https://www.google.com/maps/search/?api=1&query=40%2C-70以便它实际上显示了字段中描述的纬度/经度。
<table>
<tr>
<th>Name</th>
<th>Address</th>
<th>Zip Code</th>
</tr>
<tbody>
{% for pl in markers %}
<tr>
<td>{{pl.fields.name}}</td>
<td><a href="https://www.google.com/maps/search/?api=1&query="pl.fields.latitude"%2C"pl.fields.longitude">{{pl.fields.address}}</a></td>
<td>{{pl.fields.zip}}</td>
</tr>
{% endfor %}
</tbody>
这是输出的内容:
这些链接应该指向 google maps API 的纬度/经度,但现在它不起作用。我该怎么做呢?
解决方案
额外的引号把它扔掉了。
<table>
<tr>
<th>Name</th>
<th>Address</th>
<th>Zip Code</th>
</tr>
<tbody>
{% for pl in markers %}
<tr>
<td>{{pl.fields.name}}</td>
<td><a href="https://www.google.com/maps/search/?api=1&query={{pl.fields.latitude}},{{pl.fields.longitude}}">{{pl.fields.address}}</a></td>
<td>{{pl.fields.zip}}</td>
</tr>
{% endfor %}
</tbody>
推荐阅读
- python - 更改 matplotlib pyplot scatterplot 上的点大小
- python-2.7 - VSCODE pytest 不构造 sys.path 与命令行 pytest 相同
- html - 在 GitLab 中创建一个 HTML 项目
- javascript - 如何使用 javascript 作为数组从烧瓶中读取变量?
- android - 扫描二维码/条形码后如何打开另一个活动?
- kubernetes - 如何使用 kops 更新 Kubernetes 集群图像参数
- npm-install - Bitbucket 管道,npm 安装失败
- python - PyGears hdlgen 不生成 DTI 定义文件
- spring-boot - Spring Boot 验证列表中的每个字符串(kotlin)
- react-native - React Navigation:Android 上类似于 iOS 的 Modal Stack