extInfoWindow gUtility

1,105 views
Skip to first unread message

Scott Haines

unread,
Sep 6, 2009, 5:29:08 PM9/6/09
to Google Maps JavaScript API v3
Hello Everyone,
I am new to this group and before working on updating the source code
for the extinfowindow.js (originally written by Joe Monahan
http://www.seejoecode.com), I wanted to know if anyone in the group
has updated the extension to the infoWindow to work in version 3 of
the maps code.

If anyone has any other secrets which make an external hack irrelevant
please let me know. I am embarking on a v3 maps project and need to
clear the default infoWindow chrome to supply my own custom chrome.
Thanks.

Cheers,
Scott Haines
Newfront Creative

Scott Haines

unread,
Sep 6, 2009, 5:30:12 PM9/6/09
to Google Maps JavaScript API v3
http://gmaps-utility-library-dev.googlecode.com/svn/trunk/extinfowindow/docs/examples.html#HowTo
is the original link I found the v2 code at that I want to update to
v3.

On Sep 6, 2:29 pm, Scott Haines <sc...@newfrontproductions.com> wrote:
> Hello Everyone,
> I am new to this group and before working on updating the source code
> for the extinfowindow.js (originally written by Joe Monahanhttp://www.seejoecode.com), I wanted to know if anyone in the group

Esa

unread,
Sep 6, 2009, 5:58:24 PM9/6/09
to Google Maps JavaScript API v3

Scott Haines

unread,
Sep 7, 2009, 3:25:08 PM9/7/09
to Google Maps JavaScript API v3
Esa,
You are the best. This is exactly what I wanted and it is great that
the community has already worked through this issue. I can't thank you
enough.

Cheers,
Scott Haines
Newfront Creative

Scott Haines

unread,
Sep 7, 2009, 5:31:05 PM9/7/09
to Google Maps JavaScript API v3
I found that the svn infobox js is different than the html example. I
prefer the js that was in the html version. I appended the InfoBox
function to include the opts.html, so that it is easier to work with.
(basically a hybrid of the checked in js, and the html)

function InfoBox(opts) {
google.maps.OverlayView.call(this);
this.latlng_ = opts.latlng;
this.map_ = opts.map;
this.html_ = opts.html;
this.offsetVertical_ = -195;
this.offsetHorizontal_ = 0;
this.height_ = 165;
this.width_ = 266;

var me = this;
this.boundsChangedListener_ =
google.maps.event.addListener(this.map_, "bounds_changed", function
() {
return me.panMap.apply(me);
});

// Once the properties of this OverlayView are initialized, set its
map so
// that we can display it. This will trigger calls to panes_changed
and
// draw.
this.set_map(this.map_);
}

then line 84 becomes: contentDiv.innerHTML = this.html_;

Then it is easier to execute in my opinion than the InfoBox
(latlng,map,opts) version where you have more confusion and bits of
overhead.

In HTML:

var iWindowHTML = '<div id="wrap_div">'+
'<div class="tTitle">'+
'<h3 class="mainTitle">your title</h3>'+
'<div class="cur_place">icon_or_something</div>'+
'</div>'+
'<div class="main-content">'+
'your contents'+
'</div>'+
'</div>';

google.maps.event.addListener(team, 'click', function(e) {
var infoBox = new InfoBox({latlng: team.get_position(), map:map, html:
iWindowHTML});
});

----------
What I found really nice about this approach is that you can
completely kill the need to run a predetermined infoBox background,
you can specify everything as simple DOM and css and you render your
infoBox even quicker!

I am making a Facebook application (currently in private alpha) that
needed to be able to think quickly and run in a completely dynamic
environment so the approach provided by Esa (infobox.js) and a little
hack to simplify the code was the perfect solution. Think about using
Ajax to call the contents of iWindowHTML, return and display that info
within the box. The solution is then extremely light weight. I will
upload my rev code in a little bit.

Cheers,
Scott Haines
Newfront Creative

On Sep 7, 12:25 pm, Scott Haines <sc...@newfrontproductions.com>
wrote:

Scott Haines

unread,
Sep 7, 2009, 7:40:09 PM9/7/09
to Google Maps JavaScript API v3
The infoBox function doesn't allow for a proper toggle effect from the
marker therefore making a user 'have' to click on the close icon to
actually close the window. So I added an addition to the construct on
an object to object basis.

google.maps.event.addListener(team, 'click', function(e) {
if(!document.getElementById('infoBox')){
var infoBox = new InfoBox({latlng: team.get_position(), map:map,
html: iWindowHTML, width:350,height:'auto'});
} else {
document.getElementById('infoBox').parentNode.removeChild
(document.getElementById('infoBox'));
}
});

What I have done is add on line 70 of infobox.js the following :
div.id = 'infoBox';
div.name = 'infoBox';

Now you can control specific nodes (markers) on the map.

Now I can go full circle and properly bobble the marker and infoBox.

Cheers,
Scott Haines
Newfront Creatve

pamela (Google Employee)

unread,
Sep 7, 2009, 7:45:53 PM9/7/09
to google-map...@googlegroups.com
Thanks, Scott. Please update the thread with your final code when it's
done. The custom infowindow demos were more of a proof-of-concept than
a fully-featured infowindow, so it's great to have you putting
together a more complete example.

- pamela

Douglass Davis

unread,
Feb 5, 2013, 12:06:24 AM2/5/13
to google-map...@googlegroups.com


On Monday, February 4, 2013 5:33:43 AM UTC-5, Douglass Davis wrote:

I am working on extinfowindow for google api v3 as well, since I haven't been able to find the code online.

http://devservices.northcarolina.edu/lcl/ded_gmap/system/themes/asp/js/extinfowindow.js

Here is an example of its use:

http://devservices.northcarolina.edu/lcl/ded_gmap/exams/find.php

I have added some custom modifications though. If any one wants to add it to some repository, feel free too.

I am having one problem. I am not sure whether this is a google maps API v3 bug or what, and no one answers my questions on stackoverflow:
http://stackoverflow.com/questions/14400354/how-can-i-stop-overlay-click-from-going-to-map-or-detect-its-an-overlay-click

Basically, there is no way to stop a a click event on the infowindow. it always goes through to the map. None of this works to stop the event:


// overlay click event handler ExtInfoWindow.prototype.onClick_ = function(e) { var evt = e ? e:window.event; evt.cancelBubble = true; evt.returnValue = false; if (evt.stopPropagation) { evt.stopPropagation(); } evt.stop(); // from google.maps.MouseEvent };


Btw: I figured out the click event problem, so that should be fixed.

 

chris marx

unread,
Apr 30, 2013, 2:27:21 PM4/30/13
to google-map...@googlegroups.com
Thanks for posting this, works great

Douglass Davis

unread,
May 1, 2013, 1:01:37 AM5/1/13
to google-map...@googlegroups.com
It still has a problem in chrome where links in the infowindow don't work.  The user clicks on them and nothing happens.  However, if I don't "steal" the click event and try to stop it, then the click will go right through to the map.  And the click on the map closes the infowindow.  Not sure how to fix this one.

Douglass Davis

unread,
May 1, 2013, 12:54:30 PM5/1/13
to google-map...@googlegroups.com
changed the way event handling works so that mouse scroll wheel on InfoWindow won't zoom.  newest version here:

http://online.northcarolina.edu/system/themes/asp/js/extinfowindow.js

chris marx

unread,
May 1, 2013, 2:09:10 PM5/1/13
to google-map...@googlegroups.com
In chrome, it seems evt.stopPropagation()  is all that is necessary for the click event to not affect the map,  which makes sense since that's what stopPropagation is for.   did you discover a  specific need in chrome  for cancelBubble or  returnValue?


On Wednesday, May 1, 2013 1:01:37 AM UTC-4, Douglass Davis wrote:

Douglass Davis

unread,
May 1, 2013, 2:56:30 PM5/1/13
to google-map...@googlegroups.com
Good point. So, I went back to using an event handler from a previous version which does one or the other:

ExtInfoWindow.prototype.cancelEvent_ = function(e) {

 if( (navigator.userAgent.toLowerCase().indexOf('msie') != -1  && document.all) ||
                  navigator.userAgent.indexOf('Opera') > -1)  {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  } else {
    e.stopPropagation();
  }
   return false;;
}

And I removed the click handling hack. Also, Re: my previous post, instead of trying to cancel mouse scroll events, now, whenever the user mouses over the infowindow, I just turn zoom by scroll wheel off until they mouse out.

Updated code is here:

http://online.northcarolina.edu/system/themes/asp/js/extinfowindow.js

- Doug

Douglass Davis

unread,
May 6, 2013, 7:52:05 AM5/6/13
to google-map...@googlegroups.com

chris marx

unread,
May 8, 2013, 3:52:10 PM5/8/13
to google-map...@googlegroups.com
 I can get  it to highlight with a right-click,  sure there is no on mouse down or click cancel function somewhere still in there?

Doug Davis

unread,
Sep 26, 2015, 10:03:41 PM9/26/15
to Google Maps JavaScript API v3, sc...@newfrontproductions.com
FYI:  New version with improved event handling here:

http://online.northcarolina.edu/system/themes/asp/js/extinfowindow.js

Problem with not being able to select text in the infowindow has been corrected (thanks Josh Holiday).
Reply all
Reply to author
Forward
0 new messages