Sevgili StackOverflowers Merhaba
I am new to web programming and finding the server-client mixture confusing. I have written very simple code which accepts a PHP 2D array [index][keys] (from a query) to just draw markers on a Google map (JavaScript). It works. But it doesn't look right to me! Is this indeed the correct way to pass the values from my PHP array into the Javascript functions?
Thanks in advance Ari
Yine netlik için düzenlemek, 4 boşluk, tavsiye için teşekkür eklendi!
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title><?php echo $title;?></title
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=GoogleMapsKey"
type="text/javascript">
</script>
<script type="text/javascript" language="JavaScript">
var m_map;
//Add one marker.
function addmarker(iLat, iLon)
{
var point = new GLatLng(iLat, iLon);
m_map.addOverlay(new GMarker(point));
}
function initialize()
{
if (GBrowserIsCompatible())
{
m_map = new GMap2(document.getElementById("map_canvas"));
m_map.setCenter(new GLatLng(37.4419, -122.1419), 1);
m_map.setUIToDefault();
<?php foreach($query as $item):?>
var oLat = '<?php echo $item['lat'];?>';
var oLon = '<?php echo $item['lon'];?>';
addmarker(oLat, oLon);
<?php endforeach;?>
}
}// End initialize()
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px" ></div>