hey luke. i am developing on a local server but here is the code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; >
  <head>
    <script type="text/javascript"
src="http://www.google.com/jsapi?key=ABQIAAAAN_IKAOv-fz9s2G9ZOihkhRQaINUKgwP2Yc6w43xxEJabtFceLhTLaDYAByaQCpjBLzLz5o6UvuqMHg";></script>
    <script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true";></script>
    <style type="text/css">
      html, body, #map_canvas {width: 100%; height: 100%; margin: 0;
padding: 0;}
    </style>
  </head>
  <body onload="init()">
    <div id="map_canvas"></div>
  </body>
    <script type="text/javascript">
  //<![CDATA[

   function init() {

     if (google.loader.ClientLocation)
        {
            var currentLocation;

            currentLocation = google.loader.ClientLocation;

            var clientLatlng = new
google.maps.LatLng(currentLocation.latitude,
currentLocation.longitude);
            var myOptions = {   zoom: 13,
                                center: clientLatlng,
                                mapTypeId: google.maps.MapTypeId.TERRAIN
                            };

            var map = new
google.maps.Map(document.getElementById("map_canvas"), myOptions);
        };

        downloadUrl("ReadRows.php", function(data) {
        var xml = parseXml(data);
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var address = markers[i].getAttribute("address");
          var type = markers[i].getAttribute("type");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("lat")),
              parseFloat(markers[i].getAttribute("lng")));
          var html = "<b>" + name + "</b> <br/>" + address;
          var icon = customIcons[type] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon,
            shadow: icon.shadow
          });
          bindInfoWindow(marker, map, infoWindow, html);
        }
      });

    };

    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    };

    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;

      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request.responseText, request.status);
        }
      };

      request.open('GET', url, true);
      request.send(null);
    }

    function parseXml(str) {
      if (window.ActiveXObject) {
        var doc = new ActiveXObject('Microsoft.XMLDOM');
        doc.loadXML(str);
        return doc;
      } else if (window.DOMParser) {
        return (new DOMParser).parseFromString(str, 'text/xml');
      }
    }

    function HomeControl(controlDiv, map) {

                // Set CSS styles for the DIV containing the control
                // Setting padding to 5 px will offset the control
                // from the edge of the map
                controlDiv.style.padding = '5px';

                // Set CSS for the control border
                var controlUI = document.createElement('DIV');
                controlUI.style.backgroundColor = 'white';
                controlUI.style.borderStyle = 'solid';
                controlUI.style.borderWidth = '1px';
                controlUI.style.cursor = 'pointer';
                controlUI.style.textAlign = 'center';
                controlUI.title = 'Add a New Location to Map';
                controlDiv.appendChild(controlUI);

                // Set CSS for the control interior
                var controlText = document.createElement('DIV');
                controlText.style.fontFamily = 'Arial,sans-serif';
                controlText.style.fontSize = '12px';
                controlText.style.paddingLeft = '4px';
                controlText.style.paddingRight = '4px';
                controlText.innerHTML = 'Add Point';
                controlUI.appendChild(controlText);

                google.maps.event.addDomListener(controlUI, 'click', function() 
{
                var htmlAdd = "<table>" +
                 "<tr><td>Name:</td> <td><input type='text'
id='name'/> </td> </tr>" +
                 "<tr><td>Address:</td> <td><input type='text'
id='address'/></td> </tr>" +
                 "<tr><td>Type:</td> <td><select id='type'>" +
                 "<option value='bar' SELECTED>bar</option>" +
                 "<option value='restaurant'>restaurant</option>" +
                 "</select> </td></tr>" +
                 "<tr><td></td><td><input type='button' value='Save &
Close' onclick='saveData()'/></td></tr>";

                infowindowAdd = new google.maps.InfoWindow({
                        content: htmlAdd });
                        
                        google.maps.event.addListener(map, "click", function() {
                        infowindowAdd.open(map, marker); });
                google.maps.event.addListener(map, "click", function(event) {
                        marker = new google.maps.Marker({
                        position: event.latLng,
                        map: map  });
                });
                        controlUI.style.backgroundColor = 'red';
                });
        }

    var customIcons = {
      restaurant: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      },
      bar: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      }
    };


    function doNothing() {}


 //]]>
</script>

</html>

On Tue, Apr 13, 2010 at 4:56 PM, Luke Mahé <[email protected]> wrote:
> Hi,
> Are you able to supply a link to an example?
> Thanks
> Luke
>
> On Mon, Apr 12, 2010 at 11:56 AM, Beach Bum <[email protected]> wrote:
>>
>> I added a UI control to my map to 'Add Point' to a MySQL db. When
>> clicked, there are two addListener events. One creates a new marker,
>> the other opens an infowindow. The issue I am having is that when the
>> UI control is clicked and the user clicks the map the first time, a
>> marker is added but the infowindow does not show. However, when the
>> map is clicked additional times the marker is added and the infowindow
>> pops up (which is what I want). Has anyone encountered this problem of
>> it not working properly the first time clicked?
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Maps JavaScript API v3" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to