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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:10:42+00:00 2026-06-06T14:10:42+00:00

I am using the GMAP3 jquery plugin. I am using the following example to

  • 0

I am using the GMAP3 jquery plugin.

I am using the following example to add an infowindow http://gmap3.net/api/add-info-window.html

How can i make the infowindow close when a the mouse is clicked away from the infowindow?

So far i tried

var inside = false;
$('.infowindow').live('mouseenter',function(){ 
    inside=true; 
}).live('mouseleave', function(){ 
    inside=false; 
});
$("body").mouseup(function(){ 
    if(!inside) $('.infowindow').remove();
});

But this keeps the infowindow open but removes the content from the infowindow class.

i have been trying infowindow.close() but cant get it working?

EDIT: Here is the addinfowindow function

function addInfoWindow(lati, longi, name, datestring) {
  // get address
  $("#dispatcher").gmap3({
    action: 'getAddress',
    latLng: [lati, longi],
    callback: function (results) {
      content = results && results[1] ? results && results[1].formatted_address : 'No Address';

      // create infowindow       
      $('#dispatcher').gmap3({
        action: 'addInfoWindow',
        latLng: [lati, longi],
        infowindow: {
          options: {
            content: name
          },
          events: {
            closeclick: function (infowindow, event) {
              //alert('closing : ' + $(this).attr('id') + ' : ' + infowindow.getContent());
            }
          },
          apply: [{
            action: 'setContent',
            args: ['<span class="infowindow">' + name + '<br />' + content + '<br />' + datestring + '<span>']
          }]
        }
      });

    } // end callback

  });
}
  • 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-06T14:10:44+00:00Added an answer on June 6, 2026 at 2:10 pm

    If closing on mouse click outside of info window is desired action, following code should work:

    var map = creteMap();
    var infoWindow = createInfoWindow(map);
    
     google.maps.event.addListener(map, 'click', function() {
           infoWindow.setMap(null);
     });
    

    Note that createMap() and createInfoWIndow are abstracted. Click event won’t trigger when clicking infow window itself, as it is “above” map object.

    Instead of creating infowindow like

    $('#dispatcher').gmap3({
            action: 'addInfoWindow',
            latLng: [lati, longi],
            infowindow: {
              options: {
                content: name
              },
              events: {
                closeclick: function (infowindow, event) {
                  //alert('closing : ' + $(this).attr('id') + ' : ' + infowindow.getContent());
                }
              },
              apply: [{
                action: 'setContent',
                args: ['<span class="infowindow">' + name + '<br />' + content + '<br />' + datestring + '<span>']
              }]
            }
          });
    

    You should add infoWindow outside of GMAP3 plugin like:

    function createInfoWindow(lati, longi, mapDivId,mapOptions, infowindowHtml){
      var map = new google.maps.Map(document.getElementById(mapDivId),mapOptions);
    
      var latLng = new google.maps.LatLng(lati,lngi);
      var infoWindow = new google.maps.InfoWindow();
      infoWindow.setContent(infowindowHtml);
      infoWindow.setPosition(latLng);
      google.maps.event.addListener(map, 'click', function() {
           infoWindow.setMap(null);
       });
    
      infoWindow.open(map);
    }
    

    For reference on map options take a look at this example

    Disclaimer: I haven’t tested this code, so there may be typos and such, but that’s the way to do it outside of GMAP3 plugin.

    Edit: Using GMAP3 plugin, it should be doable this way, though I haven’t tried it:

        $('#dispatcher').gmap3({
            action: 'addInfoWindow',
            latLng: [lati, longi],
            callback : function(infoWindowObj) { 
                   if(infoWindowObj.getMap() != null){
                          infoWindowObj.getMap().addListener(map, 'click', function() {
                               infoWindowObj.setMap(null); });
    
                   }
            },
            infowindow: {
              options: {
                content: name
              },
              events: {
                closeclick: function (infowindow, event) {
                  //alert('closing : ' + $(this).attr('id') + ' : ' + infowindow.getContent());
                }
              },
              apply: [{
                action: 'setContent',
                args: ['<span class="infowindow">' + name + '<br />' + content + '<br />' + datestring + '<span>']
              }]
            }
          });
    

    Please do let me know if this one works.

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

Sidebar

Related Questions

I'm trying to create a map using gmap3.net plugin with Jquery, the script should
Using jQuery plugin gMap from http://gmap.nurtext.de/ . I can't understand why the first (commented
I am using gmaps.js plugin http://hpneo.github.com/gmaps/ The Sliding Zoom Control and the InfoWindow don't
I am using the jquery-ui-map plugin (http://code.google.com/p/jquery-ui-map/). I have successfully created a map using
I am using http://code.google.com/p/jquery-ui-map/ HTML: <div id=map_canvas style=width: 100%; height:400px; latitude=123456 longitude=123456>Loading Map</div> jQuery
I am using the gmap3 jquery plugin and need a little help. I have
I'm using the google maps API with openstreetmap (see the following example code), I'd
I'm using a great jQuery plugin called GMaps3 to display a map on a
Im using jQuery to modify html that has been created with other javascript. If
1) I have a site, using jQuery and the gMap Google Maps plugin. This

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.