This is my code:
function geocode(){
var country_code ='us';
// var country_code ='';
// if (country_code) var country_code = read_cookie('country');
// country_code = country_code.toLowerCase();
var GeoCoded = { done: false };
var input = document.getElementById('loc');
var options = { types: [], componentRestrictions: { 'country': country_code } };
It is designed to pull the cookie value stored on the users computer and set it to the component_restrictions value for the autosuggest. However, the problem I am having is, if the user doesnt have a cookie set, the value is empty. The componentRestriction only seems to work if there is a value there.
For example if I use this line it works:
var country_code ='us';
If I use this line it doesnt:
var country_code ='';
I want it to work so that if there is no cookie set then there is no componentRestriction so it autosuggests all countries. This only seems to work when I remove this code entirely:
componentRestrictions: { 'country': country_code } }
Adjust options object based on cookie vs no cookie