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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:08:47+00:00 2026-05-27T21:08:47+00:00

I have a PHP script that generates a list of places and I need

  • 0

I have a PHP script that generates a list of places and I need to add those to a Google map on the same page. In spite of the MANY tutorials online, I haven’t been able to find a straightforward way of doing this. I’m curious to know if there’s a simple javascript/php snippet to do this… without resorting to a JQuery plugin, etc.

<ul id="myPlaces">
<li name="Pan Africa Market" address="1521 1st Ave, Seattle, WA" lat="47.608940" lng="-122.340141" type="restaurant">Pan Africa Market</li>
<li name="Buddha Thai & Bar" address="2222 2nd Ave, Seattle, WA" lat="47.613590" lng="-122.344391" type="bar"/>Buddha Bar</li>
<li name="The Melting Pot" address="14 Mercer St, Seattle, WA" lat="47.624561" lng="-122.356445" type="restaurant"/>Melting Pot</li>
</ul>

The Google Map would simply contain markers with these locations on it. Naturally the locations would change, so they can’t be hard-coded.

  • 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-27T21:08:48+00:00Added an answer on May 27, 2026 at 9:08 pm

    Plain jQuery can do this for you with the each function. For the code example you need a google maps object:

    $('#myPlaces li').each(function(index, el) {
    
        new google.maps.Marker({
            position: new google.maps.LatLng($(el).attr("lat"), $(el).attr("lng")),
            map: map,
            title: $(el).attr("name")
        });
    
    });
    

    See the doku for more informations:

    • http://api.jquery.com/each
    • http://code.google.com/intl/en-EN/apis/maps/documentation/javascript/reference.html#Marker

    In plain JS it is more code to write and it can be done with the getElementsByTagName function which you can call on the document or a child node:

    var i, list, places, place, lat, lng, placeName;
    
    list = document.getElementById("myPlaces");
    places = list.getElementsByTagName("li");
    
    for (i = 0; i < places.length; i += 1) {
        place = places[i];
        lat = place.getAttribute("lat");
        lng = place.getAttribute("lng");
        placeName = place.getAttribute("name");
    
        new google.maps.Marker({
            position: new google.maps.LatLng(lat, lng),
            map: map,
            title: placeName
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a php script that generates a list of links that match
I have a PHP script on a server that generates the XML data on
I have a script that generates images from text using PHP. It's working fine
Basically I have a php script located on a sever that generates a JSON
I have this test page http://thechozenfew.net/projects/write_font.php that generates the text in the input box
I have a PHP script that generates an RSS feed using some external data
So I have a small PHP script that generates an xml feel for the
I have a php script that generates a pdf report. When we go to
I have a PHP script that generates table rows with hidden input tags that
I have a php script that generates a binary file (is some kind of

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.