如何在 jsfiddle中重现此插件?到目前为止的代码在这里。我的问题是 - 我可以看到使用 firebug 的每个请求都有响应数据,但没有显示自动完成列表。谢谢你们的时间。
直接从小提琴添加代码 - HTML:
<!-- required js libraries -->
<script type="text/javascript" src="jquery-1.7.1.min.js"></script> <!-- jQuery is directly loaded from fiddle, so in the live example I skipped this line -->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://gmap3.net/js/gmap3-4.1-min.js"></script>
<script type="text/javascript" src="https://raw.github.com/jbdemonte/autocomplete/master/jquery-autocomplete.min.js"></script>
<!-- this is required to help autocomplete plugin -->
<link rel="stylesheet" type="text/css" href="https://raw.github.com/jbdemonte/autocomplete/master/jquery-autocomplete.css" />
<input type="text" id="address" size="60"/>
<div id="test" style="height:350px; width:600px"></div>
这是javascript:
/*This one initializes the map*/
$("#test").gmap3();
/*This is the autocomplete code*/
$('#address').autocomplete({
source: function() {
$("#test").gmap3({
action:'getAddress',
address: $(this).val(),
callback:function(results){
if (!results) return;
$('#address').autocomplete(
'display',
results,
false
);
}
});
},
cb:{
cast: function(item){
return item.formatted_address;
},
select: function(item) {
$("#test").gmap3(
{action:'clear', name:'marker'},
{action:'addMarker',
latLng:item.geometry.location,
map:{center:true}
}
);
}
}
});