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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:21:07+00:00 2026-05-15T14:21:07+00:00

Is it possible to programmatically generate markers in Google? For example, I have a

  • 0

Is it possible to programmatically generate markers in Google? For example, I have a database of services and locations that I want to plot on a Google Map using PHP.

Using the Maps API v3, I have created a map and plotted the services fine using markers and info windows, but what I really want to do is generate numbers (1,2,3,4… etc.) in the default marker bubbles based on the order they get retrieved from the DB. Also, I’d like to change the colour of the marker icon programmatically based on the service type in the database.

I’m using PHP, so don’t know if there’s a script to do this, but I had hoped that Google would provide this custom marker generation through the API.

  • 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-15T14:21:08+00:00Added an answer on May 15, 2026 at 2:21 pm

    Have PHP spit out javascript code.

    Here’s a little convenience javascript function that I wrote to add a marker with a window associated.

    function add_marker(opts, place) {
      var marker = new google.maps.Marker(opts);
      marker.place_id = place.id;
      markers[place.id] = marker;
      var infowindow = new google.maps.InfoWindow({
        content: place.details
      });
    
      infowindows[place.id] = infowindow;
    
      google.maps.event.addListener(marker, 'click', function() {
        infowindows[marker.place_id].open(map,marker);
      });
    
     }
    

    So after declaring that in some javascripty place, you’d then have some PHP that’d probably resemble (and assuming your map is a global called ‘map’):

    <script type="text/javascript">
      <?php 
      $count = 0;
      foreach ($rowset as $row): ?>
      add_marker({
            position: new google.maps.LatLng(<?php echo $row->lat ?>, <?php echo $row->lng ?>),
            title:<?php echo $row->title ?>,
            map:map
        }, { id:'<?php echo $count ?>', details:'<?php echo $row->details ?>' });
      <?php 
      $count++;
      endforeach; ?>
    </script>
    

    I haven’t tested any of this nor do I have any idea what the data looks like, but that method should work for what you’re wanting. I’m not 100% sure what you mean by custom marker generation, because it sounds like you’re already doing that, just not through PHP.

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

Sidebar

Related Questions

Is it possible to programmatically create VPN profile on Android (assuming that I have
Is it possible, using AS3, to programmatically generate a .swf file? What my little
Is it possible to programmatically zip/unzip files in vb.net? Meaning, not that it will
Is it possible to programmatically invoke default search functionality of IE using ASP.net ,
In .NET is it possible to generate class diagrams (.cd) programmatically (C#)? If so
I have a need to generate SQL queries against a variety of database providers,
I am trying to programatically generate movie/video file using Google Earth COM APIs (along
Is it possible to create a flash file programmatically using C# or VB.net? I
I have a quoting system that can generate several variants of a quote. these
Is it possible to generate keyboard inputs in my Xul app programmatically?

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.