There is no built in function like drupal_remove_js() to do that.
// set the central point $lonlat = array( 'lon' => $lon, 'lat' => $lat, ); // add it to Drupal.settings drupal_add_js(array(‘mySetting’ => array('center'=> $lonlat)), array('type' => 'setting'));
case 'setting': $js_element = $element; $js_element['#value_prefix'] = $embed_prefix; $js_element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");"; $js_element['#value_suffix'] = $embed_suffix; $output .= theme('html_tag', array('element' => $js_element)); break;
Ideally drupal_add_js() would have prevented this by checking the existence of a settings before it is added.
The only trick is calling &drupal_static() rather than calling drupal_add_js() as the former gives you a pointer and later is giving same list as a copy, the list you get from drupal_add_js() is a copy of static data, so changes to the copy are not persisted to static data store.
[Added 18 Oct 2013]
If a setting does need to have multiple values, it is better to put them in a keyed array, a good example is system settings.ajax which is keyed by element id
$element['#attached']['js'] = array( 'type' => 'setting', 'data' => array('ajax' => array($element['#id'] => $settings)), );