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 4624218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:05:57+00:00 2026-05-22T03:05:57+00:00

Hey. I’mm trying to put two points on a single map with same div

  • 0

Hey. I’mm trying to put two points on a single map with same div id..
but it doesn’t work..
code:

for 1st,

  var map = new GMap2(document.getElementById("map-canvas"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setCenter(new GLatLng(<?=$lat;?>,<?=$lng;?>), 6);

  var point = new GLatLng(<?=$lat;?>,<?=$lng;?>);
  var marker = createMarker(point,'Welcome:<b></b><br>Second Info Window with an image<br><img src="http://localhost/gps/user_photo/" width=80 height=80>')
  map.addOverlay(marker);


  function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }

for 2nd,

  var map = new GMap2(document.getElementById("map-canvas"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setCenter(new GLatLng(<?=$mylat;?>,<?=$mylng;?>), 6);

  var point1 = new GLatLng(<?=$mylat;?>,<?=$mylng;?>);
  var marker = createMarker1(point1,'Welcome:<b></b><br>Second Info Window with an image<br><img src="http://localhost/gps/user_photo/" width=80 height=80>')
  map.addOverlay(marker);


  function createMarker1(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }

why two points not shown in one map?????
and it will seen in two different maps…

  • 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-05-22T03:05:57+00:00Added an answer on May 22, 2026 at 3:05 am
      //set up map as before
    
      var point0 = new GLatLng(<?=$mylat0;?>,<?=$mylng0;?>);
      var point1 = new GLatLng(<?=$mylat1;?>,<?=$mylng1;?>);
      var marker0 = createMarker(point0,'Welcome:<b></b><br>First Info Window etc);
      var marker1 = createMarker(point1,'Welcome:<b></b><br>Second Info Window etc);
      map.addOverlay(marker);
    
    // only declare this once
      function createMarker(point,html) {
            var marker = new GMarker(point);
            GEvent.addListener(marker, "click", function() {
              marker.openInfoWindowHtml(html);
            });
            return marker;
          }
    

    This is one way of doing it just to get it working for you, but essentially the js points and markers should be arrays which you loop through – ditto probably the $mylat and $mylong vars in PHP.

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

Sidebar

Related Questions

Hey guys, am trying to write to do type casting in java, but i
Hey, I'm trying to get the source code of an app similar to the
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey, in the Programming Pearls book, there is a source code for setting, clearing
Hey having some trouble trying to maintain transparency on a png when i create
Hey, I need to do my drawing over a panel in C# but without
Hey guys I have a query that selects data and organizes but not in
hey huys im counting my table with this code: $county = mysql_query(SELECT COUNT(id) from
Hey there, I'm at the moment trying to make a product management application. The
Hey guys. I'm not much of a programmer, but still need to do some

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.