gpt4 book ai didi

javascript - 将变量从 python 传递到 javascript

转载 作者:行者123 更新时间:2023-12-03 12:38:42 25 4
gpt4 key购买 nike

我必须变量xx = 38.929787yy = 22.675781

如何将它们从 python 传递到 javascript 中的 GLatLng(lat,long) 并具有 lat = xx 和 long =yy

def pymapjs(self):
""" Returns complete javacript for rendering map """

self.js = """\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=%s\" type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {


function Point(lat,long,html,icon) {
this.gpoint = new GMarker(new GLatLng(lat,long),icon);
this.html = html;

}

最佳答案

这样做:

self.js = """\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=%s\" type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {


function Point(lat,long,html,icon) {
this.gpoint = new GMarker(new GLatLng(%f,%f),icon);
this.html = html;

}""" % (xx, yy)

关于javascript - 将变量从 python 传递到 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23609548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com