IHMC Internship Test

by salitrapraveen

HTML

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<!-- the Google Map will be displayed here -->
<div id="google_map">
</div>

<!-- this section will be used for logging purpose -->
<section id="console">  
</section>

CSS

#google_map {
    width: 90%;
    height: 300px;
    margin: 20px auto;
}

#console {
    width: 90%;
    background-color: #fff;
    color: #222;
    font-family: monospace;
    font-size: 12px;
    margin: auto;
}

JavaScript

//SOLUTION BY: PRAVEEN SALITRA

var MYAPP = {

    map: null,
    //can be useful to save a reference to the Google Map object
    data: { //the definition of the points of interest that have to be displayed
        'banks': [
            {
            lat: 29.14505,
            lng: -82.189993},
        {
            lat: 29.653236,
            lng: -82.422619}
        ],
        'universities': [
            {
            lat: 29.679888,
            lng: -82.430461}
        ],
        'power companies': [
            {
            lat: 29.203575,
            lng: -81.039404},
        {
            lat: 28.538235,
            lng: -81.377389}
        ]
    },

    log: function(message) {
        //The code to display log messages in the logging area should go here
        if (message == 'countPOI') { //task1:Printing # of point of interests
            var A = [],
                temp;
            var totalPOI = 0;

            //traversing the data
            for (var p in this.data) {
                if (p) {
                    temp = this.data[p];
                    A[A.length] = p + ': ' + temp.length;
                    totalPOI += temp.length;
                }
            }

            var str = 'Total # of Point of Interests : ' + totalPOI + '<BR> <B>CATEGORY-WISE</B><BR>' + A.join('<BR>');
            //print this info to console
            document.getElementById("console").innerHTML = str;
        }
        else {
            //for some other cases, if any
            document.getElementById("console").innerHTML = message;
        }
    },


    google_init: function(centerLat, centerLng) {
        //The code to initialize a Google Map centered in centerLat, centerLng
        //should go here
        var myOptions = {
            zoom: 1,
            center: new google.maps.LatLng(centerLat, centerLng),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        this.map = new google.maps.Map(
       ...