Last active
November 18, 2017 16:34
-
-
Save vinaydotblog/34d9b2292e27f0bfee28 to your computer and use it in GitHub Desktop.
Revisions
-
Vinay Aggarwal revised this gist
Nov 18, 2017 . 1 changed file with 4 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,16 +17,11 @@ function getCity(latlng) { .done(function(data){ var location; if( data.results && data.results.length ) { var components = data.results[0]; if( components.formatted_address ) { location = components.formatted_address; return def.resolve(location); } } return def.reject(); -
Vinay Aggarwal revised this gist
Nov 18, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ function getCity(latlng) { var components = data.results[0].address_components; for(var i = 0; i < components.length; i++) { if( components[i].long_name ) { location = components[i].long_name; break; } -
Vinay Aggarwal revised this gist
Nov 18, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,7 @@ */ function getCity(latlng) { var $ = jQuery; var def = $.Deferred(); $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng=' + latlng) -
Vinay Aggarwal revised this gist
Feb 21, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,8 @@ function getCity(latlng) { var def = $.Deferred(); $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng=' + latlng) .done(function(data){ var location; if( data.results && data.results.length ) { var components = data.results[0].address_components; -
Vinay Aggarwal revised this gist
Feb 21, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,8 @@ * $elem.val( cityName ) * }); * * Info: jQuery is required for $.Deferred() and $.getJSON to work! * Regardless of everything modify it as per your convenience :) */ function getCity(latlng) { -
Vinay Aggarwal revised this gist
Feb 21, 2016 . No changes.There are no files selected for viewing
-
Vinay Aggarwal revised this gist
Feb 21, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function getCity(latlng) { var def = $.Deferred(); $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng=' + latlng).done(function(data){ var location; if( data.results && data.results.length ) { var components = data.results[0].address_components; -
Vinay Aggarwal renamed this gist
Feb 21, 2016 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ /* * Pass it your string of latlong and it'll return a promise to come back with the locality, city. * * getCity('12.9715987,77.5945627').done(function(cityName){ * $elem.val( cityName ) * }); * * Info: jQuery is required for $.Deferred() to work! */ function getCity(latlng) { var def = $.Deferred(); -
Vinay Aggarwal created this gist
Feb 21, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ function getCity(latlng) { var def = $.Deferred(); $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng=12.9715987,77.5945627').done(function(data){ var location; if( data.results && data.results.length ) { var components = data.results[0].address_components; for(var i = 0; i < components.length; i++) { if( ~components[i].types.indexOf('locality') ) { location = components[i].long_name; break; } } if(location) return def.resolve(location); } return def.reject(); }) .fail(function(){ def.reject(); }); return def.promise(); }