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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:13:02+00:00 2026-05-15T13:13:02+00:00

I am currently working on an application that pulls Google Map locations from an

  • 0

I am currently working on an application that pulls Google Map locations from an XML file and loads them into the map. Currently the Load() function is attached to the body tag. IOW, body onLoad=”load()” onunload=”GUnload()”.

I’m working in a PHP environment so I’ve created one file that does the mapping and I want to include it in numerous places, pages, and just pass it different params for different maps.

That said, I’m not sure how to initiate the load() function except on the body tag. That, of course, is a problem if I simply include the file in a different page because a second body tag would invalidate my HTML.

Here’s the load function:

function load() {
    if (isCompatible) {
        // Create Map
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(40, -90), 3);

        // Add controls
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());

        resetPolygon();

       GDownloadUrl("<?php echo $XML; ?>", function(data) {
 var xml = GXml.parse(data);
 var markers_xml = xml.documentElement.getElementsByTagName("marker");
 var bounds = new GLatLngBounds();
 for (var i = 0; i < markers_xml.length; i++) {
  var listid = markers_xml[i].getAttribute("lid");
   var voterid = markers_xml[i].getAttribute("voterid");
   var contacted = markers_xml[i].getAttribute("contacted");
var name = markers_xml[i].getAttribute("name");
var address = markers_xml[i].getAttribute("address");
var type = markers_xml[i].getAttribute("type");
var iconcolor = markers_xml[i].getAttribute("iconcolor");
var point = new GLatLng(parseFloat(markers_xml[i].getAttribute("lat")),
      parseFloat(markers_xml[i].getAttribute("lng")));
if(contacted == '2'){
 var thecolor = "#CCCCCC"
}else{
 var thecolor = iconcolor
}

var marker = createMarker(point, voterid, name, address, type, thecolor, listid);
map.addOverlay(marker);
bounds.extend(point);
markers.push(marker);
markers[i].voterid = voterid;
markers[i].contacted = contacted;
 }
 map.setZoom(map.getBoundsZoomLevel(bounds));
 map.setCenter(bounds.getCenter()); 

});
updatePoints();

    }
}

If you need more info, let me know. Any help is greatly appreciated.

  • 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-15T13:13:03+00:00Added an answer on May 15, 2026 at 1:13 pm

    I figured it out. Run the window.onload=load with Javascript after the element is loaded.

    So:

    <div id="map" style="width: 98%; height: 525px; float:left; margin: 0 1% 0 1%"></div>
    <script type="text/javascript">
    
    window.onload=load;
    
    function load() {
        if (isCompatible) {
            // Create Map
            map = new GMap2(document.getElementById("map"));
            map.setCenter(new GLatLng(40, -90), 3);
    
            // Add controls
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
    
            resetPolygon();
    
           GDownloadUrl("<?php echo $XML; ?>", function(data) {
              var xml = GXml.parse(data);
              var markers_xml = xml.documentElement.getElementsByTagName("marker");
              var bounds = new GLatLngBounds();
              for (var i = 0; i < markers_xml.length; i++) {
                var listid = markers_xml[i].getAttribute("lid");
                var voterid = markers_xml[i].getAttribute("voterid");
                var contacted = markers_xml[i].getAttribute("contacted");
                var name = markers_xml[i].getAttribute("name");
                var address = markers_xml[i].getAttribute("address");
                var type = markers_xml[i].getAttribute("type");
                var iconcolor = markers_xml[i].getAttribute("iconcolor");
                var point = new GLatLng(parseFloat(markers_xml[i].getAttribute("lat")),
                                        parseFloat(markers_xml[i].getAttribute("lng")));
                if(contacted == '2'){
                    var thecolor = "#CCCCCC"
                }else{
                    var thecolor = iconcolor
                }
    
                var marker = createMarker(point, voterid, name, address, type, thecolor, listid);
                map.addOverlay(marker);
                bounds.extend(point);
                markers.push(marker);
                markers[i].voterid = voterid;
                markers[i].contacted = contacted;
              }
              map.setZoom(map.getBoundsZoomLevel(bounds));
              map.setCenter(bounds.getCenter()); 
            });
            updatePoints();
    
        }
    }
    

    That was the answer to the issue. Thanks to all who took a look.

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

Sidebar

Ask A Question

Stats

  • Questions 524k
  • Answers 524k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In theory you can implement your own IBytecodeProvider / ProxyFactory… May 16, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer I'd switch from MAX to SUM (with 1 rather than… May 16, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer Yes, you can use the File API for this. Here's… May 16, 2026 at 10:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am currently working on this application(C#,WPF,LINQ2XML,.NET 4.0) that displays details for 'Animals'. An
I'm currently working on an application that needs to use Windows and Forms authentication
I'm currently working on a Flash application that needs to save files to Drupal.
I'm currently working on a windows application which is entirely model, that is, it
I'm working on an application that will have attachments, and I would like to
I'm currently working on an app that allows the user to play (automatically scroll)
I am currently working on an app that uses a broadcastreceiver to check for
I'm currently working on an application to validate and parse CSV-files. The CSV files
I am currently working on an application for the health care industry for my
Am working on a Java application that requires me to display PDF documents within

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.