2015-05-26 153 views
0

我正在使用Django框架。在我的模板中,我有一个变量{{i.slot.place.latitude}}和其他是{{i.slot.place.longitude}} 我想在谷歌地图的Java脚本中使用这些变量。这是 -在模板中传递Django变量JS

<script type="text/javascript"> 

    var map; 

    var myCenter = new google.maps.LatLng({{interview.slot.location.place.latitude}} ,{{ interview.slot.location.place.longitude }}); 
    var marker = new google.maps.Marker({ 
     position: myCenter 
    });` 

在这里google.maps.LatLng我想给这些变量,但它不工作。有人能告诉我正确的方法吗?

+0

使用此'变种myCenter =新google.maps.LatLng( '{{interview.slot.location.place.latitude}}',“{{采访.slot.location.place.longitude}}')' – Gocht

+0

我试过这个但不工作 – NewPie

+0

'{{i.slot.place.latitude}}'和{{interview.slot.location.place。纬度}}'? – Leistungsabfall

回答