function initializeMap() {

    var locations;
    var descriptions;
    var mapOptions = {
        disableDefaultUI: true
    };

    map = new google.maps.Map(document.querySelector('#map'), mapOptions);

    // locationFinder() returns an array of every location string from the JSONs written for bio, education, and work.

    function locationFinder() {

        // initializes an empty array
        var locations = [];

        // adds the location of birth and death:
        locations.push(bio.birth.location);
        locations.push(bio.death.location);

        // iterates through school locations and appends each location to the locations array
        var lengthSchools = education.schools.length;
        for (var school = 0; school < lengthSchools; school++) {
            locations.push(education.schools[school].location);
        }

        // iterates through work locations and appends each location to the locations array
        var lengthJobs = work.jobs.length;
        for (var job = 0; job < lengthJobs; job++) {
            locations.push(work.jobs[job].location);
        }

        return locations;
    }

    /*
    createMapMarker(placeData) reads Google Places search results to create map pins.
    placeData is the object returned from search results containing information about a single location.
    */
    function createMapMarker(placeData) {

        // The next lines save location data from the search result object to local variables
        var lat = placeData.geometry.location.lat();  // latitude from the place service
        var lon = placeData.geometry.location.lng();  // longitude from the place service
        var name = placeData.name;   // name of the place from the place service
        var bounds = window.mapBounds;            // current boundaries of the map window

        // marker is an object with additional data about the pin for a single location
        var marker = new google.maps.Marker({
            map: map,
            position: placeData.geometry.location,
            // changing the original icon map
            icon: './images/mapa.png'
        });
        
        // the content inside the windows that opens when we click the markers in the map
        var contentString = '<div id="content"><div id="siteNotice"></div>' +
        '<h1 id="firstHeading" class="firstHeading">' + name + '</h1>' +        
        '</div>';

        // infoWindows are the little helper windows that open when you click or hover over a pin on a map.
        // They usually contain more information about a location.
        var infoWindow = new google.maps.InfoWindow({
            // Here to put the info that will show up in the windows
            content: contentString
        });

        // hmmmm, I wonder what this is about...
        google.maps.event.addListener(marker, 'click', function () {
            infoWindow.open(map, marker);
        });

        // this is where the pin actually gets added to the map.
        // bounds.extend() takes in a map location object
        bounds.extend(new google.maps.LatLng(lat, lon));
        // fit the map to the new marker
        map.fitBounds(bounds);
        // center the map
        map.setCenter(bounds.getCenter());
    }

    /*
    callback(results, status) makes sure the search returned results for a location.
    If so, it creates a new map marker for that location.
    */
    function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            createMapMarker(results[0]);
        }
    }

    // pinPoster(locations) takes in the array of locations created by locationFinder() and fires off Google place searches for each location
    function pinPoster(locations) {

        // creates a Google place search service object. PlacesService does the work of actually searching for location data.
        var service = new google.maps.places.PlacesService(map);

        // Iterates through the array of locations, creates a search object for each location
        var lengthLocations = locations.length;
        for (var place = 0; place < lengthLocations; place++) {

            // the search request object
            var request = {
                query: locations[place]
            };

            // Actually searches the Google Maps API for location data and runs the callback function with the search results after each search.
            service.textSearch(request, callback);
        }
    }

    // Sets the boundaries of the map based on pin locations
    window.mapBounds = new google.maps.LatLngBounds();

    // locations is an array of location strings returned from locationFinder()
    locations = locationFinder();

    // pinPoster(locations) creates pins on the map for each location in the locations array
    pinPoster(locations);
}
// Start here! initializeMap() is called when page is loaded.
Start here. initializeMap() is called when page is loaded.
Start here . initializeMap () is called when page is loaded .
function initializeMap() {
    var locations;
    var descriptions;
    var mapOptions = {
        disableDefaultUI: true
    };
    map = new google.maps.Map(document.querySelector('#map'), mapOptions);
    function locationFinder() {
        var locations = [];
        locations.push(bio.birth.location);
        locations.push(bio.death.location);
        var lengthSchools = education.schools.length;
        for (var school = 0; school < lengthSchools; school++) {
            locations.push(education.schools[school].location);
        }
        var lengthJobs = work.jobs.length;
        for (var job = 0; job < lengthJobs; job++) {
            locations.push(work.jobs[job].location);
        }
        return locations;
    }
    function createMapMarker(placeData) {
        var lat = placeData.geometry.location.lat();  
        var lon = placeData.geometry.location.lng();  
        var name = placeData.name;   
        var bounds = window.mapBounds;            
        var marker = new google.maps.Marker({
            map: map,
            position: placeData.geometry.location,
            icon: './images/mapa.png'
        });
        var contentString = '<div id="content"><div id="siteNotice"></div>' +
        '<h1 id="firstHeading" class="firstHeading">' + name + '</h1>' +        
        '</div>';
        var infoWindow = new google.maps.InfoWindow({
            content: contentString
        });
        google.maps.event.addListener(marker, 'click', function () {
            infoWindow.open(map, marker);
        });
        bounds.extend(new google.maps.LatLng(lat, lon));
        map.fitBounds(bounds);
        map.setCenter(bounds.getCenter());
    }
    function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
            createMapMarker(results[0]);
        }
    }
    function pinPoster(locations) {
        var service = new google.maps.places.PlacesService(map);
        var lengthLocations = locations.length;
        for (var place = 0; place < lengthLocations; place++) {
            var request = {
                query: locations[place]
            };
            service.textSearch(request, callback);
        }
    }
    window.mapBounds = new google.maps.LatLngBounds();
    locations = locationFinder();
    pinPoster(locations);
}
function initializeMap ( ) { var locations ; var descriptions ; var mapOptions = { disableDefaultUI : true } ; map = new google . maps . Map ( document . querySelector ( '#map' ) , mapOptions ) ; function locationFinder ( ) { var locations = [ ] ; locations . push ( bio . birth . location ) ; locations . push ( bio . death . location ) ; var lengthSchools = education . schools . length ; for ( var school = 0 ; school < lengthSchools ; school ++ ) { locations . push ( education . schools [ school ] . location ) ; } var lengthJobs = work . jobs . length ; for ( var job = 0 ; job < lengthJobs ; job ++ ) { locations . push ( work . jobs [ job ] . location ) ; } return locations ; } function createMapMarker ( placeData ) { var lat = placeData . geometry . location . lat ( ) ; var lon = placeData . geometry . location . lng ( ) ; var name = placeData . name ; var bounds = window . mapBounds ; var marker = new google . maps . Marker ( { map : map , position : placeData . geometry . location , icon : './images/mapa.png' } ) ; var contentString = '<div id="content"><div id="siteNotice"></div>' + '<h1 id="firstHeading" class="firstHeading">' + name + '</h1>' + '</div>' ; var infoWindow = new google . maps . InfoWindow ( { content : contentString } ) ; google . maps . event . addListener ( marker , 'click' , function ( ) { infoWindow . open ( map , marker ) ; } ) ; bounds . extend ( new google . maps . LatLng ( lat , lon ) ) ; map . fitBounds ( bounds ) ; map . setCenter ( bounds . getCenter ( ) ) ; } function callback ( results , status ) { if ( status == google . maps . places . PlacesServiceStatus . OK ) { createMapMarker ( results [ 0 ] ) ; } } function pinPoster ( locations ) { var service = new google . maps . places . PlacesService ( map ) ; var lengthLocations = locations . length ; for ( var place = 0 ; place < lengthLocations ; place ++ ) { var request = { query : locations [ place ] } ; service . textSearch ( request , callback ) ; } } window . mapBounds = new google . maps . LatLngBounds ( ) ; locations = locationFinder ( ) ; pinPoster ( locations ) ; }
Start here!
Start here!
// locationFinder() returns an array of every location string from the JSONs written for bio, education, and work. // initializes an empty array // adds the location of birth and death: // iterates through school locations and appends each location to the locations array // iterates through work locations and appends each location to the locations array /*
    createMapMarker(placeData) reads Google Places search results to create map pins.
    placeData is the object returned from search results containing information about a single location.
    */ // The next lines save location data from the search result object to local variables // latitude from the place service // longitude from the place service // name of the place from the place service // current boundaries of the map window // marker is an object with additional data about the pin for a single location // changing the original icon map // the content inside the windows that opens when we click the markers in the map // infoWindows are the little helper windows that open when you click or hover over a pin on a map. // They usually contain more information about a location. // Here to put the info that will show up in the windows // hmmmm, I wonder what this is about... // this is where the pin actually gets added to the map. // bounds.extend() takes in a map location object // fit the map to the new marker // center the map /*
    callback(results, status) makes sure the search returned results for a location.
    If so, it creates a new map marker for that location.
    */ // pinPoster(locations) takes in the array of locations created by locationFinder() and fires off Google place searches for each location // creates a Google place search service object. PlacesService does the work of actually searching for location data. // Iterates through the array of locations, creates a search object for each location // the search request object // Actually searches the Google Maps API for location data and runs the callback function with the search results after each search. // Sets the boundaries of the map based on pin locations // locations is an array of location strings returned from locationFinder() // pinPoster(locations) creates pins on the map for each location in the locations array