我正在使用 Smarty,我想使用谷歌地图,并在其上动态放置标记,我得到了以下 cod
{literal}
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
// ==== first part of the select box ===
var select_html = '<select onChange="handleSelected(this)">' +
'<option selected> - Select a location - <\/option>';
// =====================================
var gmarkers = [];
var htmls = [];
var i = 0;
var rozmiar = new google.maps.Size(12,20);
var punkt_startowy = new google.maps.Point(0,0);
var punkt_zaczepienia = new google.maps.Point(0,0);
var map;
var n=0;
var side_bar_html = "";
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
var ikona1 = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_blue.png");
// A function to create the marker and set up the event window
function createMarker(point,name,html,ikon) {
var options = {
draggable: true,
title: name,
icon: ikon,
clickable:true}
var marker = new GMarker(point,options);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
// ======= Add the entry to the select box =====
select_html += '<option> ' + name + '<\/option>';
// ==========================================================
i++;
map.addOverlay(marker);
return marker;
}
// ======= This function handles selections from the select box ====
// === If the dummy entry is selected, the info window is closed ==
function handleSelected(opt) {
var i = opt.selectedIndex - 1;
if (i > -1) {
GEvent.trigger(gmarkers[i],"click");
}
else {
map.closeInfoWindow();
}
}
var wspolrzedne = new google.maps.LatLng(51.730430542940184,19.62158203125);
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.730430542940184,19.62158203125), 6);
{/literal}
{foreach from=$znacznik key=key item=item}
{foreach from=$item key=k item=v}
//here
createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);
//here
{/foreach}
{/foreach}
{literal}
}else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Community Church Javascript Team
// http://www.bisphamchurch.org.uk/
// http://econym.org.uk/gmap/
//]]>
</script>
{/literal}
标签之间(//这里)这些代码是问题
createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);
它没有显示 ex 的变量。{if $k == 'nazwa_obiektu'}{$v}{/if} 什么也没显示,当我在其他地方执行 foreach 函数时,它会显示变量,但是如果我手动输入它会显示它有人知道如何解决它吗?