1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Google Maps

Multiple Maps on One Page

Having two maps (or even more) in the page is no more difficult than having just the one map. All that we need to do is to place the code for each of our two maps inside the load function making sure that each map used different variable names for each of the maps. The easiest way to do this is to just add numbers to the end of the variable names where ever they occur . For example here is what the load function looks like if we combine the maps from tutorials 3 and 8 into the same page.

function load() {
  if (GBrowserIsCompatible()) {
    var map1 = new GMap2(document.getElementById("map"));
    map1.setCenter(new GLatLng(37.4419, -122.1419), 17);

    var map2 = new GMap2(document.getElementById("map1"));
    var point = new GLatLng(-33.9419, 150.9473);
    map2.setCenter(point, 10);
    var marker = new GMarker(point);
GEvent.addListener(marker2, "click", function() {marker.openInfoWindowHtml('here I am');});
    map2.addControl(new GSmallMapControl());
    var mapControl = new GMapTypeControl();

Here's the first map.

Here's the second map in the same page.

See More About

©2017 About.com. All rights reserved.