troubleshooting Question

jQuery Issue

Avatar of Robert Granlund
Robert GranlundFlag for United States of America asked on
JavaScriptjQuery
11 Comments1 Solution111 ViewsLast Modified:
I have posted a few times about a Google API issue and I have narrowed it down.

Apparently to get the Google Map API on any browser you do not need to include document ready.  The Initialize Map function ( function initMap() )  has a function nested in it called  ( function countriesLoad() ) LINE 24.

The code below works in all browsers but IE 9.  The  ( function countriesLoad() ) does not fire.  Everything else does.

Any suggestions?

<script>
var map;

function initMap() {


  map = new google.maps.Map(document.getElementById('map'), {
    zoom: 1,
    center: {lat: 0, lng: 0}
  });
  map.setOptions({styles: styles});

var countries = [];
var states = [];
var cities = [];
function unique(array) {
    return $.grep(array, function(el, index) {
        return index === $.inArray(el, array);
    });
}

 

function countriesLoad() {
  jQuery.each(json_data.features, function() {
      countries = countries.concat((jQuery(this)[0].properties.countriesSupported));
      states = states.concat((jQuery(this)[0].properties.state));
      cities = cities.concat((jQuery(this)[0].properties.city));
    });
  console.log(countries);
  countries = countries.filter(Boolean);
  console.log(countries);

  countries = unique(countries);
  console.log(countries);
  countries = countries.sort();
  console.log(countries);
  states = states.filter(Boolean);
  states = jQuery.unique(states);
  states = states.sort();
  cities = cities.filter(Boolean);
  cities = jQuery.unique(cities);
  cities = cities.sort();
  //<option value="australia">Australia</option>
  
  for (i = 0; i < countries.length; i++) {
     
    $("#country_select").append('<option value="' + countries[i] + '">' + countries[i] +'</option>');
    $("#country_select_2").append('<option value="' + countries[i] + '">' + countries[i] +'</option>');

  }

  for (i = 0; i < states.length; i++) {
    jQuery("#state_select").append('<option value="' + states[i] + '">' + states[i] +'</option>');
  }
  for (i = 0; i < cities.length; i++) {
    jQuery("#city_select").append('<option value="' + cities[i] + '">' + cities[i] +'</option>');
  }

};




};
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros