I have a problem that I just cannot understand. I took an application that uses google maps API version 3. I was not very familiar with this, but I was asked to adapt a few things. One of them entails the creation of custom infoBubbles, and not the use of the default infoWindow, so that we can fine-tune them. I found a class called infoBox that will do just that and follow some examples to get to where I am now. However, my application requires that each overlay (polygon, polyline or marker) has a delete button on the infoBox. The deletion was just fine with the jQuery click event when we used infoWindow by default, but now itβs very strange that I use infoBox. I created a small test file that demonstrates the problem. The bottom line is that when you open infoBox for the first time, the procedure for the uninstall button is performed only once. But as soon as you close the window and open it again (or another), the procedure starts several times. The more times you open infoBoxes, the more time the delete button is re-attached and, in turn, executed. I have things wrapped in a domready listener for infoBox, so that I can change the elements in the window to be specific to the properties of the object I click on. For some reason, domready shoots several times (I thought it would only start once), and my delete click is bound again. Before using the infoBox class for a regular info window, domready is not required to use jQuery to change the name and description, and the click event has never been linked again and again. I completely lost and spent too much time on this. Any help would be greatly appreciated. An example of a test file is as follows:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script> <script type="text/javascript" src="infobox.js"></script> <script type="text/javascript" src="jquery-1.9.0.min.js"></script> <script type="text/javascript"> </script> <title>Creating and Using an InfoBox</title> </head> <body onload="initialize()"> <div id="map_canvas" style="width: 100%; height: 400px"></div> <p> This example shows the "traditional" use of an InfoBox as a replacement for an InfoWindow. </body> </html>
It might be easier to see a live demo at http://midwestfish.djcase.com/infobox/test.html
source share