<script type="text/javascript">
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(17.72356,100.07335),13);
map.setUIToDefault();
function initialize(){
if (GBrowserIsCompatible()) {
/*****Load XML createMarker******/
GDownloadUrl("xml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
var bounds = new GLatLngBounds();
for (var i = 0; i < markers.length; i++) {
var map_id = markers[i].getAttribute("map_id");
var type = markers[i].getAttribute("type");
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(map_id,point,type);
map.addOverlay(marker);
}
});
}
}
/***********End XML*****************/
//ตรงนี้ เปงกรอบกำหนดแผนที่
/*******Function createMarker**********************/
function createMarker(map_id,point,type){
var customIcons = [];
var icon = new GIcon(G_DEFAULT_ICON);
icon.image = 'icon/icon1.png';
icon.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
icon.iconSize = new GSize(20, 20);
icon.shadowSize = new GSize(1, 1);
icon.iconAnchor = new GPoint(12, 8);
icon.infoWindowAnchor = new GPoint(5, 1);
customIcons["ทุเรียน"] = icon; // ชื่อ type images icon
var icon2 = new GIcon();
icon2.image = 'icon/icon2.png';
icon2.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
icon2.iconSize = new GSize(20, 20);
icon2.shadowSize = new GSize(1, 1);
icon2.iconAnchor = new GPoint(12, 8);
icon2.infoWindowAnchor = new GPoint(5, 1);
customIcons["ลางสาด"] = icon2; // ชื่อ type images icon
var marker = new GMarker(point, customIcons[type]);
var html = "<div class=\"view-map\">ทดสอบจุด point จากดาต้าเบส <li class=\"photo\">ยังไม่มีรูป<li class=\"text\">ชื่อพื้นที่เกษตรกรรม :"+name+"</li><li class=\"text\">ยังไม่ได้ใส่</li><li class=\"text\">ยังไม่ได้ใส่</li></ul></div>"
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
</script>
ต้องไปแก้ที่ File xml ด้วยรึเปล่า
file xml
<markers>
<!--SiXhEaD:result-->
<marker map_id ="$map_id" lat ='$point_x' lng ='$point_y' type = "ทุเรียน"/>
<!--/SiXhEaD:result-->
</markers>