Trigger del geotag


/ Published in: jQuery
Save to your folder(s)

trugg


Copy this code and paste it in your HTML
  1. var timeoutLocalita = 0;
  2. $("#localita").live('keyup', function() {
  3. clearTimeout(timeoutLocalita);
  4. timeoutLocalita = setTimeout('checkPosizione()', 500);
  5. });
  6.  
  7. function checkPosizione() {
  8. console.log('vado con: ' + $("#localita").val() );
  9. $.post('/elementi/geotag', { where: $("#localita").val() }, function(res) {
  10. console.log(res);
  11. if(res.status == 'OK') {
  12. $("#localitaHelper").html(
  13. 'Selezionato: ' +
  14. res.results[0].address_components[2].long_name +
  15. '<input type="hidden" name="lat" value="'+ res.results[0].geometry.location.lat + '" /><input type="hidden" name="lng" value="'+ res.results[0].geometry.location.lng +'" />');
  16. } else {
  17. $("#localitaHelper").html('Risultato: Località poco accurata.');
  18. }
  19. }, 'json');
  20.  
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.