How to iterate through Drupal.settings in a js file when there are lots of variables?
You can add your module name to settings like this

$locations = array();
for($i=0; $i &lt; $length; $i++) {
  $locations[] = array('a'.$i =&gt;array(
    'lat'=&gt; $form_state['storage']['results'][$i]['geometry']['location']['lat'],
    'long'=&gt; $form_state['storage']['results'][$i]['geometry']['location']['long'],  
  );
}

drupal_add_js(array('mymodule' =&gt; $locations), 'setting');


and loop is js like

for (var x in Drupal.settings.mymodule) {
  // ...
}