карта гугл где пользователи могут устанавливать координаты, стаит драгабле пин , не очень удобно перетаскивать пин, да и пользователи всегда кликают и не понимают что пин нужно тянуть скажите как поменять draggable на клик ( что бы при клике на нужно место устанавливался пин).
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
<html>
<head>
<meta http-equiv="content-type" content="text/html; utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="../style/template_adm.css" type="text/css"/>
<link rel="stylesheet" href="../style/gmap_two.css" type="text/css"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var address;
var geocoder;
var map;
var marker
var x=25.215825;
var y=55.273611;
<?
if($_GET['adr'])
echo "\n address='".urldecode($_GET['adr'])."';";
else
echo "\n address='Moscow';";
?>
// Карта + передвижной маркер с обновлением координат
function initialize() {
//geocoder = new google.maps.Geocoder();
var myLatlng = new google.maps.LatLng(x,y);
var myOptions = {
zoom: 12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
}
document.getElementById('spot-lat').value = x.toFixed(4);
document.getElementById('spot-longi').value = y.toFixed(4);
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//Добавляем маркер
marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable:true,
// drop:true,
});
google.maps.event.addListener(
marker,
'drag',
function() {
document.getElementById('spot-lat').value = marker.position.lat().toFixed(4);
document.getElementById('spot-longi').value = marker.position.lng().toFixed(4);
}
);
showAddress(address);
}
// Определяем местоположение по адресу
function showAddress(address) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
marker.position=results[0].geometry.location;
document.getElementById('spot-lat').value = marker.position.lat().toFixed(4);
document.getElementById('spot-longi').value = marker.position.lng().toFixed(4);
} else {
alert("Ups something wrong: " + status);
}
});
}
function save_address() {
var x = document.getElementById('spot-lat').value;
var y = document.getElementById('spot-longi').value;
window.opener.document.getElementById('map_x').value = x;
window.opener.document.getElementById('map_y').value = y;
self.close ();
}
</script>
</head>
<body onload="initialize()" >
<div id="map_canvas" style="width: 700px; height: 520px"></div>
<div id="search_form">
<form method="post" action="#" onsubmit="showAddress(this.address.value); return false">
<p id="blok-gmap2" >DRAG THE PIN ON YOUR LOCATION->PRESS "SAVE" </p>
<!--<input type="text" size="30" name="address" value="" />
<input class="submit" type="submit" name="submit1" value="Search" />-->
</form>
</div>
<div id="coord_form">
<form name="form2" action="#" onsubmit="save_address(); return false">
<input readonly="1" class="input-medium" name="lat" id="spot-lat" value="" /><!--
-->
<input readonly="1" class="input-medium" name="longi" id="spot-longi" value="" /><!--
-->
<!--<span class=sp>
After
маркера не забудьте
сохранить изменения
</span>-->
<!--
-->
<input class="submit_2gmap" type="submit" name="submit2" value="Save" />
</form>
</div>
</body>
</html>