我想在插件 gmap3 中添加自动完成输入,单击地址移动标记后,它会放置并获取纬度和经度,但我做不到。我试过:
演示:http: //jsfiddle.net/ezJUm/
<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]);
});
});
我该怎么办?