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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:14:22+00:00 2026-06-03T06:14:22+00:00

I have a google map set up to find the user’s current location, and

  • 0

I have a google map set up to find the user’s current location, and center the map at that closest marker to their location. The markers, when clicked, open up an infobox (note this is a little different than an infoWindow – http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html). What I want to do, however, is automatically open up the nearest marker without the user actually clicking. Here’s the code to trigger a marker opening:

//loop through all locations to add a marker:
addMarker = function(loc) {
    var markerLoc = new google.maps.LatLng(loc.Lat, loc.Long);

    var marker = new google.maps.Marker({
        map: map,
        position: markerLoc
    });

    google.maps.event.addListener(marker, "mousedown", function() {

        var infoOpts = {
            content: loc.markerText,
            boxStyle: { background: "none transparent", width: "180px"},
            pixelOffset: new google.maps.Size(-90, 0),
            closeBoxMargin: "5px"
        };

        var ib = new InfoBox(infoOpts);
        ib.open(map, marker);
    });

    markers.push(marker);
};

So somehow I have to trigger the mouseDown function of the appropriate marker, but it has to be done in a function outside of this one. I will have a reference to the appropriate marker in the array (markers[closestmarker]).

  • 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-03T06:14:23+00:00Added an answer on June 3, 2026 at 6:14 am

    I see that this question has been sitting for quite awhile, but, just in case, this answer may be helpful:
    trigger google maps marker click

    The code would look like this:

    var marker = new google.maps.Marker({});
    new google.maps.event.trigger( marker, 'click' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have google map code that will set a single marker on
I have a Google Map on the webpage with markers on it that has
I have an app that saves google map markers, I basically save the lat
I currently have a Google map that geocodes multiple markers on the fly but
I have a google map set up with markers supplied via a JSON feed.
I have a custom Google map set up with custom markers for certain points
I have a google map that takes and put coordinates from input fields .
Hi guys we have a google map v3 which loads in markers when dragged
I have a Google V3 map which uses steetView and some map markers. The
i have google Maps and when the user touch any point in the map

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.