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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:38:40+00:00 2026-05-30T12:38:40+00:00

All, I’m getting a couple points to create some markers in my data map.

  • 0

All,
I’m getting a couple points to create some markers in my data map. Here is my code to display the map:

var map;
var icon0;
var newpoints = new Array();

function addLoadEvent(func) { 
var oldonload = window.onload; 
if (typeof window.onload != 'function'){ 
    window.onload = func
} else { 
    window.onload = function() {
        oldonload();
        func();
    }
}
}

addLoadEvent(loadMap);

function loadMap() {
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( <?php echo $_SESSION['pav_event_latitude']; ?>, <?php echo $_SESSION['pav_event_longitude']; ?>), 12);
map.setMapType(G_NORMAL_MAP);

icon0 = new GIcon();
icon0.image = "http://www.google.com/mapfiles/marker.png";
icon0.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon0.iconSize = new GSize(20, 34);
icon0.shadowSize = new GSize(37, 34);
icon0.iconAnchor = new GPoint(9, 34);
icon0.infoWindowAnchor = new GPoint(9, 2);
icon0.infoShadowAnchor = new GPoint(18, 25);

addPoints(myStores);
}

function addPoints( points )
{   
for ( var p = 0; p < points.length; ++p )
{
    var pointData = points[p];
    if ( pointData == null ) return; 
    var point = new GLatLng( pointData.latitude, pointData.longitude );
var marker = createMarker( point, icon0, pointData.html );
map.addOverlay( marker );
}
}

function createMarker(point, icon, popuphtml) {
var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(popuphtml);
});

function Store( lat, long, text )
{
this.latitude = lat;
this.longitude = long;
this.html = text;
}

var myStores = [<?php echo $jsData;?>, null];

What I would like to do is basically get the average of all of the points created so that can be the center of my map so it shows all of my points in the map instead of just a couple of them sometimes. Has anyone ever done something like this?

Thanks for any help in advance!

  • 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-30T12:38:42+00:00Added an answer on May 30, 2026 at 12:38 pm

    I guess you are looking for google.maps.Map.fitBounds()

    This should work:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
      </script> 
    <script  type="text/javascript">
    function addLoadEvent(func) { 
    var oldonload = window.onload; 
    if (typeof window.onload != 'function'){ 
        window.onload = func
    } else { 
        window.onload = function() {
            oldonload();
            func();
        }
    }
    }
    
    var map,
        infowin=new google.maps.InfoWindow({content:'moin'});
    function loadMap() 
    {
      map = new google.maps.Map(
        document.getElementById('map'),
        {   
          zoom: 12,
          mapTypeId:google.maps.MapTypeId.ROADMAP,
          center:new google.maps.LatLng(<?php echo $_SESSION['pav_event_latitude']; ?>, 
                                        <?php echo $_SESSION['pav_event_longitude']; ?>)
        });
    
      addPoints(myStores);
    }
    
    function addPoints( points )
    {  
      var bounds=new google.maps.LatLngBounds();
      for ( var p = 0; p < points.length; ++p )
      {
        var pointData = points[p];
        if ( pointData == null ) {map.fitBounds(bounds);return; }
        var point = new google.maps.LatLng( pointData.latitude, pointData.longitude );
        bounds.union(new google.maps.LatLngBounds(point));
        createMarker( point,  pointData.html );
      }
      map.fitBounds(bounds);
    
    }
    
    function createMarker(point,  popuphtml) 
    {
      var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
      var marker = new google.maps.Marker(
        {
          position:point,
          map:map
        }
      );
      google.maps.event.addListener(marker, 'click', function() {
          infowin.setContent(popuphtml)
          infowin.open(map,marker);
        });
    
    }
    function Store( lat, long, text )
    {
    this.latitude = lat;
    this.longitude = long;
    this.html = text;
    }
    
    
    
    var myStores = [<?php echo $jsData;?>, null];
    addLoadEvent(loadMap);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, See the code below: function menu() { this.menuitem=[]; this.submenu=[]; this.menuitem[0] = $('div#sivname1'); this.menuitem[1]
All, I have some script tags that are not working in Wordpress. If I
All, Say I have the following bit of code: select: function(start, end, allDay) {
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I am trying to create a table to receive user inputs (UGC). This
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All I need is to create a file that contains a file names' list
All! I found strange code in LinkedBlockingQueue: private E dequeue() { // assert takeLock.isHeldByCurrentThread();
All, I have a guestbook feature on my site and I keep getting spammed.

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.