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

  • SEARCH
  • Home
  • 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 8363273
In Process

The Archive Base Latest Questions

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

am trying to load two markers over the googlemap but it appears that the

  • 0

am trying to load two markers over the googlemap but it appears that the map is loaded twice and i cant see both of the markers.Here is the code.

    var geocoder;
    var map;
    geocoder = new google.maps.Geocoder();
    //    var address = document.getElementById("address").value;
    //      var user='33936357';
    $.getJSON("http://api.twitter.com/1/users/lookup.json?user_id=33936357,606020001&callback=?", function (data) {
      $.each(data, function (i, item) {
        var screen_name = item.screen_name;
        var img = item.profile_image_url;
        var location = item.location;
        geocoder.geocode({
          address: location
        }, function (response, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            var x = response[0].geometry.location.lat(),
              y = response[0].geometry.location.lng();
            var mapOptions = {
              center: new google.maps.LatLng(x, y),
              zoom: 8,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
            var marker = new google.maps.Marker({
              icon: img,
              title: screen_name,
              map: map,
              position: new google.maps.LatLng(x, y)
            });
          } else {
            alert("Geocode was not successful for the following reason: " + status);
          }
        });
      });
    });

I dont know how to fix this

  • 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:08:17+00:00Added an answer on June 9, 2026 at 12:08 pm

    Your map creation is within the each loop .. try this :

    // setup the map objects
    var geocoder = new google.maps.Geocoder();;
    var mapOptions = {
          center: new google.maps.LatLng(0, 0), 
          zoom: 8,
           mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    // added this 
    var bounds = new google.maps.LatLngBounds();
    // create the map
    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    
    $.getJSON("http://api.twitter.com/1/users/lookup.json?user_id=33936357,606020001&callback=?", function (data) {
      $.each(data, function (i, item) {
        var screen_name = item.screen_name;
        var img = item.profile_image_url;
        var location = item.location;
        geocoder.geocode({
          address: location
        }, function (response, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            var x = response[0].geometry.location.lat(),
              y = response[0].geometry.location.lng(); 
            var myLatLng = new google.maps.LatLng(x, y);
            var marker = new google.maps.Marker({
              icon: img,
              title: screen_name,
              map: map,
              position: myLatLng
            });
            bounds.extend(myLatLng);
          } else {
            alert("Geocode was not successful for the following reason: " + status);
          }
        });
      });
      map.fitBounds(bounds);
    });
    

    Now you create the map one .. add the long and lat to a LatLngBounds object then set the map to fit the Bounds.

    Docs on LatLngBounds here

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

Sidebar

Related Questions

I am trying to load two modal dialog boxes with Jquery. Both of them
I am trying to load view that contains a map view and 2 buttons,
Trying to load a small .txt file into mysql but get all my data
I trying to load and save setting with this code but when I closing
I am trying to load a swf into an Ogre3d/Hikari application and that swf
I am trying to load some classes that are common to all the web
I have an XML file containing seed data that I'm trying to load into
I was trying to load a php file in html such that the menu
I'm trying to load some content into a table using insertAfter(), but the content
I've almost got it, but it doesn't quite work. I'm trying to load the

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.