<script type="text/javascript">
//<![CDATA[
var gmarkers = [];
var htmls = [];
var i = 0;
var side_bar_html = "";
var map = "";
function load()
{
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(13.77754, 100.55765), 11);
readMap();
}
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
}
function process_it(doc)
{
lines = doc.split("\n");
for(var i = 0; i < lines.length; i++)
{
if( lines[i].length > 1) {
parts = lines[i].split("|");
var lat = parseFloat(parts[0]);
var lng = parseFloat(parts[1]);
var html = parts[2];
var label = parts[3];
var CusID = parts[4];
var point = new GLatLng(lat,lng);
// create the marker
var marker = createMarker(point,label,html,CusID);
map.addOverlay(marker);
}
}
document.getElementById("side_bar").innerHTML = side_bar_html;
}
function readMap()
{
var url="mapdata.php";
var request = GXmlHttp.create();
request.open("GET", url, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var txtDoc = request.responseText;
process_it(txtDoc);
}
}
request.send(null);
}
function createMarker(point,name,html,CusID)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
if (point == "(0, 0)") {
side_bar_html += '<a href="javascript:myclick(' + i + ')"><span style="color: #F66">' + name + " " + point + '</span><\/a> <a id="various3" href="update.php?CustID=' + CusID + '"><SPAN STYLE="font-weight:bold; text-decoration: none; color: #000;">UPDATE</SPAN></a> <br>';//Display Customer NO POINT
}else{
side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '<\/a><br>';//Display Customer HAVE POINT
}
i++;
return marker;
}
function myclick(i)
{
gmarkers[i].openInfoWindowHtml(htmls[i]);
}
//]]>
</script>