Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:31:20+00:00 2026-06-09T12:31:20+00:00

Hi I’ve been using Google Maps API v3 and geocoder to display a map

  • 0

Hi I’ve been using Google Maps API v3 and geocoder to display a map and it’s working well so far. When I tried to display another map on the same page only the first map loads. The second map simply shows a gray area. No map is loaded. I have to do multiple geocoder requests, but how do I go about it. Here is my code so far:

    var geocoder;
var map;
var map2;
var marker;
var infobox;

function initialize() {
            //Geocoder
        geocoder = new google.maps.Geocoder();
        var address = 'Times Square, New York'; 
        geocoder.geocode( { 'address': address }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
            //Marker
            var companyLogo = new google.maps.MarkerImage('images/pin.png',
                new google.maps.Size(20,20),
                new google.maps.Point(0,0),
                new google.maps.Point(10,10)
                );
            //Marker shadow 
            var companyShadow = new google.maps.MarkerImage('images/pin_shadow.png',
                new google.maps.Size(25,33),
                new google.maps.Point(0,0),
                new google.maps.Point(0, 25)
                );
            //Display the marker
            var marker = new google.maps.Marker({
                map: map,
                icon: companyLogo,
                shadow: companyShadow,
                position: results[0].geometry.location,
                title:"Some title"
            });
            //Infobox
            infobox = new InfoBox({
                content: document.getElementById("infobox"),
                disableAutoPan: false,
                maxWidth: 320,
                pixelOffset: new google.maps.Size(-142, -150),
                zIndex: null,
                boxStyle: {
                    opacity: 1,
                    width: "300px"
                    },
                closeBoxMargin: "0px",
                closeBoxURL: "images/close_tooltip.png",
                infoBoxClearance: new google.maps.Size(1, 1)
                });
                        //Open infobox
            google.maps.event.addListener(marker, 'mouseover', function() {
                infobox.open(map, this);
                map.panTo(geocoder);
                });

            } else {
                alert("Geocode was not successful for the following reason: " + status);
                }
            });

                    //Map options
        var myOptions = {
            zoom: 15,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true,
            scrollwheel: false
        }
    //Call Maps 
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    map2 = new google.maps.Map(document.getElementById("map_canvas2"), myOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:31:22+00:00Added an answer on June 9, 2026 at 12:31 pm

    The myOptions object you use to set up the second map does not contain a center property, so the second map cannot be centred.

    When the geocoder is called, you set the centre of the first map:

    map.setCenter(results[0].geometry.location);
    

    but you do not set the second map.

    Without setting the map’s centre, it will remain grey and empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.