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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:50:31+00:00 2026-05-13T14:50:31+00:00

I have asked in two earlier questions to place multiple markers from a XML

  • 0

I have asked in two earlier questions to place multiple markers from a XML file created from Lightroom, which had to be tranformed in degrees instead of Degrees,Minutes,Seconds.
This part i managed but then…

The answers in the previous question were very informative but it’s my poor skill of programming (first project) that i just cannot manage to solve it.

The problem is i want to show multiple markers.

the complete code:

    <?php
    require('GoogleMapAPI.class.php');

 $objDOM = new DOMDocument("1.0", 'utf-8');

 $objDOM->preserveWhiteSpace = false;

 $objDOM->load("googlepoints.xml"); //make sure path is correct

 $photo = $objDOM->getElementsByTagName("photo");
 foreach ($photo as $value) {

    $album = $value->getElementsByTagName("album");
    $albu = $album->item(0)->nodeValue;

    $description = $value->getElementsByTagName("description");
    $descriptio = $description->item(0)->nodeValue;

    $title = $value->getElementsByTagName("title");
    $titl = $title->item(0)->nodeValue;

    $link = $value->getElementsByTagName("link");
    $lin = $link->item(0)->nodeValue;

    $guid = $value->getElementsByTagName("guid");
    $gui = $guid->item(0)->nodeValue;

    $gps = $value->getElementsByTagName("gps");
    $gp = $gps->item(0)->nodeValue;

 $Deglon = str_replace("'", "/", $gp);
 $Deglon = str_replace("°", "/", $Deglon);
 $Deglon = str_replace("", "/", $Deglon);


 $str = $Deglon;

 $arr1 = str_split($str, 11);

 $date = $arr1[0];  // Delimiters may be slash, dot, or hyphen
 list ($latdeg, $latmin, $latsec, $latrichting) = split ('[°/".-]', $date);

 $Lat = $latdeg + (($latmin + ($latsec/60))/60);

  $latdir = $latrichting.$Lat;
 If (preg_match("/N /", $latdir)) {$Latcoorl = str_replace(" N ", "+",$latdir);}
        else {$Latcoorl = str_replace ("S ", "-",$latdir);}
 //$Latcoord=$Latcoorl.",";

 $date1 = $arr1[1];  // Delimiters may be slash, dot, or hyphen
 list ($londeg, $lonmin, $lonsec, $lonrichting) = split ('[°/".-]', $date1);

 $Lon = $londeg + (($lonmin + ($lonsec/60))/60);

 $londir = $lonrichting.$Lon;

 If (preg_match("/W /", $londir)) {$Loncoorl = str_replace("W ", "+",$londir);}
        else {$Loncoorl = str_replace ("E", "-",$londir);}


$Lonarr = array($Loncoorl);
foreach ($Lonarr as &$LonArray);

$Latarr = array($Latcoorl);
foreach ($Latarr as &$LatArray);

$titarr = array($titl);
foreach ($titarr as &$titArray);

$guarr = array($gui);
foreach ($guarr as &$guaArray);

$albuarr = array($albu);
foreach ($albuarr as &$albuArray);

print_r ($LonArray);
print_r ($LatArray);

print_r ($guaArray);
print_r ($albuArray);


    $map = new GoogleMapAPI('map');
    // setup database for geocode caching
 // $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');
    // enter YOUR Google Map Key
    $map->setAPIKey('ABQIAAAAiA4e9c1IW0MDrtoPQRaLgRQmsvD_kVovrOh_CkQEnehxpBb-yhQq1LkA4BJtjWw7lWmjfYU8twZvPA');   

  $map->addMarkerByCoords($LonArray,$LatArray,$albuArray,$guaArray);
} 
?>

The problem is that the “$map->addMarkerByCoords($LonArray,$LatArray,$albuArray,$guaArray);” only shows the last value’s from the 4 arrays.

And there fore there is only one marker created.

The output (print_r) of for example the $guaArray is IMG_3308IMG_3309IMG_3310IMG_3311IMG_3312 (5 name’s of filename’s from photographs).

The function addMarkersByCoords from the ‘GoogleMapAPI.class.php’ is like this:

function addMarkerByCoords($lon,$lat,$title = '',$html = '',$tooltip = '') {
        $_marker['lon'] = $lon;
        $_marker['lat'] = $lat;
        $_marker['html'] = (is_array($html) || strlen($html) > 0) ? $html : $title;
        $_marker['title'] = $title;
        $_marker['tooltip'] = $tooltip;
        $this->_markers[] = $_marker;
        $this->adjustCenterCoords($_marker['lon'],$_marker['lat']);
        // return index of marker
        return count($this->_markers) - 1;
    }

I hope that someone can help me ?

  • 1 1 Answer
  • 1 View
  • 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-13T14:50:31+00:00Added an answer on May 13, 2026 at 2:50 pm

    You must create the new instance of the google map above the foreach

    like this

        $map = new GoogleMapAPI('map');
        // setup database for geocode caching
     // $map->setDSN('mysql://USER:PASS@localhost/GEOCODES');
        // enter YOUR Google Map Key
        $map->setAPIKey('ABQIAAAAiA4e9c1IW0MDrtoPQRaLgRQmsvD_kVovrOh_CkQEnehxpBb-yhQq1LkA4BJtjWw7lWmjfYU8twZvPA');   
    
    foreach ()
    {
    }
    

    now you are creating every loop a new map with the last coord

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

Sidebar

Related Questions

I have asked two questions earlier about this and for each post there was
extending the question I had asked earlier which can be found here, plotting multiple
The below code is from my other questions that I have asked here on
I have just asked these two questions, one on flash seo url best practices
I have asked two previous questions for taking info put into a form and
I have previously asked two questions Question 1 and Question 2 but there is
This question is related to two different questions I have asked previously: 1) Reproduce
I have inherited some HTML code and have been asked to align the two
A friend of mine asked: if I have two dice and I throw both
This is an extension of an earlier questions I asked, here: Django - Parse

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.