{"id":1021,"date":"2022-08-30T15:11:04","date_gmt":"2022-08-30T15:11:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/google-maps-api-v3-infobox-using-jquery-fadein-and-fadeout-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:11:04","modified_gmt":"2022-08-30T15:11:04","slug":"google-maps-api-v3-infobox-using-jquery-fadein-and-fadeout-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/google-maps-api-v3-infobox-using-jquery-fadein-and-fadeout-collection-of-common-programming-errors\/","title":{"rendered":"Google Maps API V3 InfoBox using jQuery fadeIn and fadeOut-Collection of common programming errors"},"content":{"rendered":"<p>I have searched the web high and low and have not been able to find a tutorial or example of using jQuery to fade an Infobox\/Infowindow in Google Maps not the content the actual box\/window. Here is my code, I&#8217;m not sure what I&#8217;m doing wrong, but something also doesn&#8217;t seem right.<\/p>\n<pre><code>`google.maps.event.addListener(marker, 'mouseover', function() {\n    ib.setContent(html);\n    ib.open(map, marker);\n    ib.setValues({type: \"point\", id: 2})\n\n   var idName = marker.get(\"id\"); \/\/I was trying to the id's of the elements here \n   var boxName = ib.get(\"id\");    \/\/to use in my jQuery\n\n   jQuery(idName ).mouseover(function() {\n      jQuery(boxName ).fadeIn('slow', function() {\n    \/\/ Animation complete\n   });\n  });\n\n});`\n<\/code><\/pre>\n<p>Thanks for your help in advance.<\/p>\n<ol>\n<li>\n<p>It is actually possible to fadein the infobox, you have to override the draw function in the infobox.js file like this<\/p>\n<pre><code>var oldDraw = ib.draw;\nib.draw = function() {\n   oldDraw.apply(this);\n   jQuery(ib.div_).hide();\n   jQuery(ib.div_).fadeIn('slow'); \n}\n<\/code><\/pre>\n<\/li>\n<li>\n<p>If you override the draw method and apply the fade in,the animation will be played even if you drag around or zoom in\/out in the map.If you don&#8217;t want that to happen,you could apply the fadeIn in the domready handler method.In that case the fade in effect will come only if you the infowindow is opened.<\/p>\n<pre><code> google.maps.event.addListener(ib, 'domready', function() {\n            jQuery(ib).hide().fadeIn('slow');\n })\n<\/code><\/pre>\n<p>;<\/p>\n<\/li>\n<li>\n<p>I am using the google utility library marker with label (http:\/\/google-maps-utility-library-v3.googlecode.com\/svn\/tags\/markerwithlabel\/1.1.5\/docs\/examples.html)<\/p>\n<p>It is easy to use jquery on the labels.<\/p>\n<pre><code>google.maps.event.addListener(marker, \"mouseover\", function (e) { \n    \/\/console.log(this); this.label.labelDiv_.style.display = 'block'; \n    $(this.label.labelDiv_).fadeIn();\n});\n\ngoogle.maps.event.addListener(marker, \"mouseout\", function (e) { \n    \/\/this.label.labelDiv_.style.display = 'none'; \n    $(this.label.labelDiv_).fadeOut();\n});\n<\/code><\/pre>\n<\/li>\n<li>\n<p>i tried something similar for a website. here is my code. (gm-api-v3)<\/p>\n<pre><code>var infowindow = new google.maps.InfoWindow({\n    content: contentString\n});\n\nfunction iwFadeIn() {\n    infowindow.open(map, marker);\n    var iw_container = $(\".gm-style-iw\").parent();\n    iw_container.stop().hide();\n    iw_container.fadeIn(1000);\n}\n<\/code><\/pre>\n<\/li>\n<li>\n<p>I do not think this is possible because Google does not provide an animation option.<\/p>\n<p>Trying to get the Dom element will not work either. The ib variable is an google.maps.InfoWindow class not a DOM element. Since there is no public interface to get the DOM element for the info window you will not be able to access this yourself.<\/p>\n<p>If you use <code>console.log(ib.get(\"id\"))<\/code> you will see that the ID is undefined.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:14:37. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have searched the web high and low and have not been able to find a tutorial or example of using jQuery to fade an Infobox\/Infowindow in Google Maps not the content the actual box\/window. Here is my code, I&#8217;m not sure what I&#8217;m doing wrong, but something also doesn&#8217;t seem right. `google.maps.event.addListener(marker, &#8216;mouseover&#8217;, function() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1021","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1021"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1021\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}