$.getScript('https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyCIeyrzeVetCiVKGvqLtNl4ocP5zX_E1jo', function(){
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/geocomplete/1.7.0/jquery.geocomplete.min.js', function(){
$("#event_auto_pickerlocation").geocomplete().bind("geocode:result", function (event, result) {
// JSONArray Results = jsonObj.getJSONArray("results");
$("#clear_location_filter").removeClass("make_it_hidden");
var data = JSON.stringify(result);
var data = JSON.parse(data);
// JSONObject zero = data.getJSONObject(0);
console.log(data.address_components);
var address_components = data.address_components;
var city = "";
var state ="";
var country ="";
for(var i=0, len=address_components.length; i<len; i++) {
var ac = result.address_components[i];
if(ac.types.indexOf("locality") >= 0) city = ac.long_name;
if(ac.types.indexOf("administrative_area_level_1") >= 0) state = ac.long_name;
if(ac.types.indexOf("country") >= 0) country = ac.long_name;
}
Session.set("filter_active","true");
Session.set("selected_city",city);
Session.set("state",state);
Session.set("country",country);
});
});
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/geocomplete/1.7.0/jquery.geocomplete.min.js', function(){
$("#event_auto_pickerlocation").geocomplete().bind("geocode:result", function (event, result) {
// JSONArray Results = jsonObj.getJSONArray("results");
$("#clear_location_filter").removeClass("make_it_hidden");
var data = JSON.stringify(result);
var data = JSON.parse(data);
// JSONObject zero = data.getJSONObject(0);
console.log(data.address_components);
var address_components = data.address_components;
var city = "";
var state ="";
var country ="";
for(var i=0, len=address_components.length; i<len; i++) {
var ac = result.address_components[i];
if(ac.types.indexOf("locality") >= 0) city = ac.long_name;
if(ac.types.indexOf("administrative_area_level_1") >= 0) state = ac.long_name;
if(ac.types.indexOf("country") >= 0) country = ac.long_name;
}
Session.set("filter_active","true");
Session.set("selected_city",city);
Session.set("state",state);
Session.set("country",country);
});
});
Comments
Post a Comment