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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:57:03+00:00 2026-06-11T06:57:03+00:00

I am trying to create marker categories and display markers on click… For example,

  • 0

I am trying to create marker categories and display markers on click…

For example, “Eat”, “Banks”, “Places of Interest” and clicking on them would produce only the markers in those categories. You can see it live HERE

Here is a code snippet:

//<![CDATA[

//<![CDATA[

var map = null;

var gmarkers = [];

var gicons = [];

var icon = [];

function initialize() {

var myOptions = {

zoom: 13,

center: new google.maps.LatLng(37.979183,-121.302381),

mapTypeControl: true,

mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},

navigationControl: true,

mapTypeId: google.maps.MapTypeId.ROADMAP

  }

map = new google.maps.Map(document.getElementById("map_canvas"),

                            myOptions);





google.maps.event.addListener(map, 'click', function() {

infowindow.close();

});



// Add markers to the map

// Set up three markers with info windows 







///////////////////////// EATS //////////////////////////////////////////////



var point = new google.maps.LatLng(37.988012,-121.311901); 

var image = 'icons/orangepointer.png';

var marker = createMarker(point,'<div style="width:205"><center><img src="icons/tigeryogurt.jpg" /></center><br><b>Tiger Yogurt</b><small><br>4343 Pacific Avenue<br>209.952.6042<br><br><a href="http://maps.google.com/maps?saddr=&daddr=' + point.toUrlValue() + '" target ="_blank">Get Directions<\/a></small><\/div>', image);

// this will be gmarkers[0]



var point = new google.maps.LatLng(37.987054,-121.311655); 

var image = 'icons/orangepointer.png';

var marker = createMarker(point,'<div style="width:205"><center><img src="icons/mwbakery.jpg" /></center><br><b>M&W Bakery<br>Cakes & Sandwiches</b><small><br>4343 Pacific Avenue<br>209.473.3828<br><br>On the web visit:<br><a href="http://www.mandwdutchamericanbakery.com" target ="_blank">MandWDutchAmericanBakery.com<\/a><br><br><a href="http://maps.google.com/maps?saddr=&daddr=' + point.toUrlValue() + '" target ="_blank">Get Directions<\/a></small><\/div>', image);

// this will be gmarkers[1]

Currently, all markers display. I can easily get the markers not to display… however, i am trying to have only categories display and individual listings to display on click only!

CREATE MARKER FUNCTION:

    }

var infowindow = new google.maps.InfoWindow(
{ 
size: new google.maps.Size(150,50)
});

function triggerClick(i) {
  google.maps.event.trigger(gmarkers[i],"click")
  };

function createMarker(latlng, html, img) {
var contentString = html;
var marker = new google.maps.Marker({
    position: latlng,
    map: map,
    icon: img,
    zIndex: Math.round(latlng.lat()*-100000)<<5
    });

google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(contentString); 
    infowindow.open(map,marker);
});
gmarkers.push(marker);
}
  • 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-11T06:57:04+00:00Added an answer on June 11, 2026 at 6:57 am

    I would think the simplest way to do it would be to assign your markers to arrays, with each marker upon creation having setMarker(null). You’d either use a separate array for each category, or a single array of objects each with a category attribute. Then when the user clicks on a category you would iterate through the appropriate array and setMarker(map) for each of its markers.

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

Sidebar

Related Questions

I am trying to create a location based search application. I need to display
I am trying to create a google map with custom icon markers. I need
I am trying to create a map with markers for Dispensers pulled from the
I am trying to create several markers along a route from google maps directions.
I am trying to create aseries of maps with markers. I have experienced, that
I am trying to create a map with 3 different markers, but currently each
I'm trying to create dynamic markers using google maps api and am having problems
I'm trying to use the Google Maps V3 API to create markers on a
I'm trying to create a Google Map with multiple markers on it, that loads
im trying to create a google marker manager but get the error message marker

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.