SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyone familiar with Google Maps API v3?

    I am trying to put together a google map for my web site for mapping locations of my photographs.

    I have put together a page which pulls data from a Mysql database, converts it to xml and then uses the xml to place markers on the map.

    I also have another map which has a sidebar (which I would like on my map), but this uses an actual coded xml file to place the markers.

    I thought it would be a straightforward case of replacing the 'call' to the xml file in the sidebar script with the 'call' to the 'php' file which generates the xml from sql in the other script.
    If only life were that simple.

    Here is the code:

    PHP Code:

          
    // original Read the data
          
    downloadUrl("categories.xml", function(doc) {
      var 
    xml xmlParse(doc);
      var 
    markers xml.documentElement.getElementsByTagName("marker");

    //   modified read data- Change this depending on the name of your PHP file
    //      downloadUrl("genxml.php", function(data) {
    //        var xml = data.responseXML;
    //        var markers = xml.documentElement.getElementsByTagName("marker");

              
            
    for (var 0markers.lengthi++) {
              
    // obtain the attribues of each marker
              
    var lat parseFloat(markers[i].getAttribute("lat"));
              var 
    lng parseFloat(markers[i].getAttribute("lng"));
              var 
    point = new google.maps.LatLng(lat,lng);
              var 
    detail markers[i].getAttribute("detail");
              var 
    name markers[i].getAttribute("name");
              var 
    html "<b>"+name+"<\/b><p>"+detail;
              var 
    category markers[i].getAttribute("category");
              
    // create the marker
              
    var marker createMarker(point,name,html,category);
            }

            
    // == show or hide the categories initially ==
            
    show("theatre");
            
    hide("golf");
            
    hide("info");
            
    // == create the initial sidebar ==
            
    makeSidebar();
          });
        } 
    The code calling the 'xml' file is lines 1-4.
    The lines I tried to replace these with which call the php file are the following 4 commented out lines. But when I comment out lines 1-4 and include these the script brakes and does not even show a map on the web page.

    There is obviously other parts of the script need altering, but I'm afraid my knowledge of scripting does not extend to identifying what.

    Anyone able to help?

    Thanks

  2. #2
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •