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

The Archive Base Latest Questions

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

I have been building an asp.net control to generate a google map based on

  • 0

I have been building an asp.net control to generate a google map based on an xml file. I have the map working, as well as the popup windows (infoWindows). Unfortunately, for some reason I cannot use the custom attributes within the XML file to populate the infoWindow for each marker. A null value is being returned when I call:
var name = markers[i].getAttribute(“name”);

I have re-written this code several different ways and I still cannot access the value. I know it exists in the xml, so I was hoping there might be someone on here with advanced knowledge of google maps api v3 and parsing xml via javascript who could help me get to the bottom of this. I have included the rendered html below, as well as the contents of the xml file partnerLocations.xml.

NOTE: I did make use of the googleUtils.js class which is provided by google and is available here: http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/util.js

testing.aspx (test page where control is implemented) rendered output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">    </script>
<script type="text/javascript" src="/includes/js/googleUtils.js"></script>
<script type="text/javascript">
    google.maps.event.addDomListener(window, 'load', function () {
        var map = new google.maps.Map(document.getElementById('map_canvas'), {
            zoom: 3,
            center: new google.maps.LatLng(52.5,-117.5),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        var infoWindow = new google.maps.InfoWindow;
        google.maps.event.addListener(map, 'click', function () {
            infoWindow.close();
        });

        downloadUrl("/includes/xml/partnerLocations.xml", function (data) {
            var markers = data.documentElement.getElementsByTagName("marker");
            for (var i = 0; i < markers.length; i++) {
                var latlng = new     google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
                var name = markers[i].getAttribute("name");
                var windowContents = "<h3>" + name + "</h3>";
                var marker = new google.maps.Marker({ position: latlng, map: map });
                bindInfoWindow(marker, map, infoWindow, windowContents);
            }
        });

        function bindInfoWindow(marker, map, infowindow, html) {
            google.maps.event.addListener(marker, 'click', function () {
                infowindow.setContent(html);
                infowindow.open(map, marker);
            });
        }
    });
</script>
<div id="map_canvas" style="width: 700px; height: 500px">
</div>

</html>

partnerLocations.xml:

<?xml version="1.0" encoding="UTF-8"?>
<markers>
  <marker lat="37.401220" lng="-122.120604" name="PartnerB" address="StreetAddress" description="Thisisourpartner..."/>
  <marker lat="37.413320" lng="-122.125604" name="PartnerB" address="StreetAddress" description="Thisisourpartner..."/>
  <marker lat="37.433480" lng="-122.139062" name="PartnerC" address="StreetAddress" description="Thisisourpartner..."/>
  <marker lat="37.445427" lng="-122.162307" name="PartnerD" address="StreetAddress" description="Thisisourpartner..."/>
</markers>
  • 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-09T13:52:21+00:00Added an answer on June 9, 2026 at 1:52 pm

    I have google maps working on my site and I’ve run your xml file in and see all locations

    Here is the code i used where test.xml is your xml file. I’ve also got the xml file in the same directory as the page displaying it

    function load() {
    var map = new google.maps.Map(document.getElementById("gmap"), {
        center: new google.maps.LatLng(50.734850, -3.536562),
        zoom: 7,
        mapTypeId: 'roadmap'
    });
    
    var infoWindow = new google.maps.InfoWindow;
    var bounds = new google.maps.LatLngBounds();
    
    // Change this depending on the name of your PHP file
    downloadUrl("test.xml", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
            var point = new google.maps.LatLng(
                parseFloat(markers[i].getAttribute("lat")),
                parseFloat(markers[i].getAttribute("lng")));
            var html = "<b>" + name + "</b> <br/>" + address;
            var icon = customIcons[type] || {};
            var marker = new google.maps.Marker({
                map: map,
                position: point,
                icon: icon.icon,
                shadow: icon.shadow
            });
            bindInfoWindow(marker, map, infoWindow, html);
            bounds.extend(point);
        }
    
        map.fitBounds(bounds);
    });
    }
    

    Yu can either use or or if using jquery using $(document).ready(function(){

    Hope it helps

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

Sidebar

Related Questions

i have been building websites using vs 2008 (mostly asp.net mvc, jquery and webforms).
With ASP.NET MVC 1.0 I always have been able to generate strongly typed links
I have an ASP.NET MVC app that I have been building, and I am
I have an issue that's been bugging me this morning. I'm building an ASP.NET
I have been building a Asp.net WCF web service with json format. Now I
I have been working on building my first CSS site using divs and am
I'm working on building a tree structure in MySQL and have been experimenting with
I'm building UI logging into a long-existing ASP.NET enterprise application. I have my own
I've been building my sample asp.net application using VWD2008 and the development virtual server
I have been developing in ASP.NET and c#, actionscript flash/flex cs3, and the iPhone.

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.