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
| $(function(){
$('#fos_user_registration_form_ville').autocomplete({
source : Routing.generate('l2_geo_town_ajax', {}),
minLength : 3,
appendTo : "#ville",
response : function(event, ui){
var lt;
var lg;
lt = parseFloat(ui.content[0].lt);
lg = parseFloat(ui.content[0].lg);
console.log(lt);
console.log(lg);
var map = new GMaps({
el: '#map',
lat: lt,
lng: lg
});
console.log(JSON.stringify(ui));
console.log(JSON.stringify(lt));
console.log(JSON.stringify(lg));
for(var i = 0; i < ui.content.length; i++){
map.addMarker({
lat : ui.content[i].lt,
lng : ui.content[i].lg,
label : (i+1) + "",
animation: google.maps.Animation.DROP,
});
}
console.log(ui.content.length);
map.fitZoom();
},
select : function(event, ui){
$('#fos_user_registration_form_idville').val(ui.item.id);
},
});
.autocomplete("instance")._renderItem = function ( ul, item ) {
alert();
console.log(item.id);
return $( "<li>" )
.append( "<div>" + item.value + " " + item.id + "</div>" )
.appendTo( ul );
};
}); |
Partager