Search Tutorials


Top Google Maps (2024) frequently asked interview questions | JavaInUse

Top Google Maps frequently asked interview questions.

In this post we will look at Google Maps Interview questions. Examples are provided with explanations.


Q: What is Google Maps?

Google Maps is a convenient way of navigating to a destination, discovering local businesses, and exploring unfamiliar areas. Google Maps stands out thanks to its user-friendly interface and navigation features Google Maps is a web mapping service developed by Google. It offers satellite imagery, aerial photography, street maps, 360° interactive panoramic views of streets (Street View), real-time traffic conditions, and route planning for traveling by foot, car, bicycle and air , or public transportation.

Q: How to plot on a Map to show location using data array(Markers)?

Multiple markers can be used as follows-
<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>
</head> 
<body>
  <div id="map" style="width: 500px; height: 400px;"></div>

  <script type="text/javascript">
    var locations = [
      ['New york', -33.890542, 151.274856, 4],
      ['Tokyo', -33.923036, 151.259052, 5],
      ['London', -34.028249, 151.157507, 3],
      ['Brussels', -33.80010128657071, 151.28747820854187, 2],
      ['Melbourne', -33.950198, 151.259302, 1]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var mapDatawindow = new google.maps.InfoWindow();

    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          mapDatawindow.setContent(locations[i][0]);
          mapDatawindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>
</body>
</html>

Q: How to remove all map markers in Google Maps?

markersArray.push(newMarker) ;
while(markersArray.length) { markersArray.pop().setMap(null); }

Q: How can we disable mouse scroll wheel scaling with Google Maps API?

options = $.extend({
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
draggable: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}, options);

Q: For Android how to launch Google Maps Direction using an intent?

We can launch Google Maps Direction using an intent as follows -
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("geo:0,0?q=37.423156,-122.084917 (" + name + ")"));
startActivity(intent);
				 

Q: How to check if Google map is fully loaded?

We can check if Google map is fully loaded as follows -
var map = new google.maps.Map(...)
map.addListener('tilesloaded', function () { ... })
				 

Q: How to calculate distance between two points in google maps?

The distance can be calculated using the computeDistanceBetween function as follows -
var latitude1 = 79.46;
var longitude1 = -6.36;
var latitude2 = 80.40;
var longitude2 = -2.68;

var distance = google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(latitude1, longitude1), new google.maps.LatLng(latitude2, longitude2)); 
				 

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions