2
我想在插件gmap3中添加自動完成輸入,在點擊地址移動標記之後放置並獲取經度和緯度,但我無法完成。我試圖爲:通過jQuery在插件gmap3中添加自動完成輸入
<div id="content">
<input id="searchTextField" type="text">
<div id="map_canvas" class="line"></div>
<div id="latlng" class="line">click the map</div>
<div id="address" class="line">click the map</div>
</div>
$(document).ready(function() {
// create the map
var map = $("#map_canvas").gmap3({
lat: 43.0566,
lng: -89.4511,
zoom: 12
});
//*********************** Autocomplete *********************************
var lat = 26.535266981346876,
lng = 54.02773082256317,
latlng = new google.maps.LatLng(lat, lng),
image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png';
mapG = new google.maps.Map(document.getElementById('map_canvas')),
marker = new google.maps.Marker({
position: latlng,
map: mapG,
icon: image
});
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, {
types: ["geocode"]
});
autocomplete.bindTo('bounds', mapG);
var infowindow = new google.maps.InfoWindow();
//*********************** Autocomplete *********************************
// add click handlers
map.onclickReverseGeocode(function (address) {
$("#address").html(address);
});
map.onclickGetLatLng(function (latlng) {
$("#latlng").html(latlng[0] + ',' + latlng[1]);
});
});
我該怎麼辦?