|
|
|
ใครรู้บ้างไหมคับ ว่า ถ้าเราต้องการ ทำมาร์ดจุด ในแผนที่ google ต้องทำอย่างไง??? |
|
|
|
|
|
|
|
ขอบคุณพี่วิน แต่ตอนนี้ก็ศึกษาจากเว็บ http://www.ninenik.com/ งมๆ อยู่ ตอนนี้ก็ติดที่ว่า อยากจะ กดที่รูปหมุด ถึงจะแสดง หมุด ไม่ใช่ Click แผนที่ถึงแสดงหมุด
โค๊ดตามนี้เลยนะคับ
Code (VB.NET)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAeNsNnRXUdrpgSw3qfvhz5hRHchrjOSPM-moa2HMmJZw-0fE6VhTsARfVd9x1Dg8TowZALqHIOcO20g" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var mark = null;
function updateHiddenFields(marker) {
latlng = marker.getLatLng();
var lng = latlng.lng();
var lat = latlng.lat();
$('marker_lat').value = lat;
$('marker_lng').value = lng;
$('marker_1').value = lat;
$('marker_2').value = lng;
}
function addMarker(latlng) {
if (!mark) {
var lat = latlng.lat();
var lng = latlng.lng();
var newMarker = new GMarker(latlng, { draggable: true, bouncy: false});
map.addOverlay(newMarker);
GEvent.addListener(newMarker, "dragend", function() {
updateHiddenFields(newMarker);
});
updateHiddenFields(newMarker);
map.panTo(latlng);
mark = true;
}
}
////////////////
function myZoomControl() {
}
myZoomControl.prototype = new GControl();
myZoomControl.prototype.initialize = function(map) {
var container = document.createElement("div");
container.style.width = "37px";
container.style.height = '100px';
var zoomInDiv = document.createElement("div");
this.setButtonStyle_(zoomInDiv,"teeden/images/zoom_in.png");//อันนี้รูป ซูม เข้าคับ
container.appendChild(zoomInDiv);
GEvent.addDomListener(zoomInDiv, "click", function() {
map.zoomIn();
});
var zoomOutDiv = document.createElement("div");
this.setButtonStyle_(zoomOutDiv,"teeden/images/zoom_out.png");//อันนี้รูป ซูม ออกคับ
container.appendChild(zoomOutDiv);
GEvent.addDomListener(zoomOutDiv, "click", function() {
map.zoomOut();
});
///////marker pic/////////
var mart = document.createElement("div");
this.setButtonStyle_(mart,"teeden/images/marker.png");//อันนี้รูป หัวหมุดคับ
container.appendChild(mart);
GEvent.addDomListener(mart, "click", function addMarker(latlng) {
map.zoomOut();
});
/////////////////////////////
map.getContainer().appendChild(container);
return container;
}
myZoomControl.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}
myZoomControl.prototype.setButtonStyle_ = function(button,button_pic) {
button.style.backgroundImage = "url(/"+button_pic+")";
button.style.width = "31px";
button.style.height = "31px";
button.style.margin = "0px 0px 3px 3px";
//styleFloat for IE
if (navigator.appName.indexOf("Netscape") != -1) {
button.style.cssFloat = "left";
}
else {
button.style.styleFloat = "left";
}
button.style.cursor = "pointer";
}
////////////////////////////////
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(18.78428,98.99334), 15);
map.addControl(new myZoomControl());
map.addControl(new GMapTypeControl());
//map.addControl(new GLargeMapControl());
GEvent.addListener(mark, "click", function(overlay, latlng) {
if (!overlay) {
addMarker(latlng);
}
});
}
}
//]]>
</script>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width:700px;height:300px">
<p> </p>
<p> </p>
</div>
<form action="/new_marker">
<input type="text" size="60" name="marker[name]" id="marker_1"/>
<input type="text" size="60" name="marker[address]" id="marker_2"/>
<input id="marker_lat" type="hidden" value="" name="marker[lat]"/>
<input id="marker_lng" type="hidden" value="" name="marker[lng]"/>
<input type="submit" value="submit" name="commit"/>
</form>
</body></html>
|
|
|
|
|
Date :
2010-12-16 10:46:02 |
By :
harry37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|