I've read some of the other posts in here about similar problems...I'm
sending in 3 addresses, one at a time for geocoding and setting
markers and extending the bounds of the map in a "setMarkers"
function.  I then want to set the zoom level based on the bounds with
"setZoom" and set the center based on the bounds with "setCenter".
This only works if I execute an "alert("Whatever")" right before the
setZoom and setCenter. I've tried delaying each execution of
setMarkers by using "setTimeout(markTime(),100)" between calls to
setMarkers to allow the geocodings time to finish, but that made no
difference. I've also tried "setTimeout('setMarkers("' + address1 + '",
0," + map + "," + bounds + ");',100)", but I don't think I setup the
single/double quotes correctly, since this did not work at all.

Please...could anybody help me patch this up?

I'm operating on XP Pro SP3, using ASP.NET 3.5 on MS Visual Studio
2008.  2 parts of code follows, first is the .aspx.vb, then the .aspx:
'********START .aspx.vb ********************************************
Partial Class property_tax_comps_tracker_GoogleMapTester
    Inherits BasePage

#Region " Declarations "

#End Region

#Region " Properties "

#End Region

#Region " Page Events "

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
        Me.Title = ""
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            SetAttributes()
        End If
    End Sub

#End Region

#Region " Control Events "

#End Region

#Region " Methods "
    Private Sub SetAttributes()
        btnSearch.Attributes.Add("onclick", "showAddress('" &
txtAddress1.ClientID & "','" & txtAddress2.ClientID & "','" &
txtAddress3.ClientID & "'); return false;")
        'btnSearch.Attributes.Add("onclick", "showAddress('100 Dundas
St W, Toronto, ON, Canada'); return false;")
    End Sub

#End Region


End Class
'******END .aspx.vb
***********************************************************
'*****START .aspx
************************************************************
<%@ Page Language="VB" MasterPageFile="~/Base/popup.master"
AutoEventWireup="false" CodeFile="GoogleMapTester.aspx.vb"
Inherits="property_tax_comps_tracker_GoogleMapTester" title="Untitled
Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphCafe"
Runat="Server">
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=ABQIAAAA3KaHauTINRDt9Mo_uXaKKxTmazC1CCL-
aZvJBl4evHylXtqSchRXl_AMYsY059CcaNzFMcDNGSqDoQ" type="text/javascript"
language="javascript">
</script>
<script type="text/javascript">
        //<![CDATA[
      var side_bar_html = "";
      var gmarkers = [];
      var i = 0;
      //var map = new GMap2(document.getElementById("map"));
      var geocoder = new GClientGeocoder();
function showAddress(addr1,addr2,addr3) {
      //alert(addr)
      var address1 = document.getElementById(addr1).value
      var address2 = document.getElementById(addr2).value
      var address3 = document.getElementById(addr3).value
      //alert("Executing showAddress for " + address);
      var map = new GMap2(document.getElementById("map"));
      var bounds = new GLatLngBounds();
      var sw = new GLatLng();
      var ne = new GLatLng();

      side_bar_html = '';
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());

      if (geocoder && GBrowserIsCompatible()) {
        //alert("Part 2 Executing showAddress for " + address);
        //alert("Starting bounds = " + bounds);
        //map.setCenter(new GLatLng(0,0),12,G_HYBRID_MAP);
        map.setCenter(new GLatLng(0,0),12)
        //setTimeout('setMarkers("' + address1 + '",0," + map + "," +
bounds + ");',100)
        //setTimeout('setMarkers("' + address2 + '",1," + map + "," +
bounds + ");',110)
        //setTimeout('setMarkers("' + address3 + '",2," + map + "," +
bounds + ");',120)
        setMarkers(address1,0,map,bounds);
        setTimeout("markTime()",200);
        setMarkers(address2,1,map,bounds);
        setTimeout("markTime()",200);
        setMarkers(address3,2,map,bounds);
        setTimeout("markTime()",200);

       ' ***NOTE: the setZoom and setCenter only works if this alert
is present!! ****
        alert("Just a pause")

        sw = bounds.getSouthWest();
        ne = bounds.getNorthEast();

        map.setMapType(G_HYBRID_MAP);
        map.setZoom(map.getBoundsZoomLevel(bounds));
        map.setCenter(bounds.getCenter());
        map.panTo(bounds.getCenter());
      }else{
        alert("Geocoder not here or Google Maps API is not compatible
with this browser!");
      }
    }

    function setMarkers(address,j,map,bounds){
        geocoder.getLatLng(
              address,
              function(point) {
                if (!point) {
                  alert(address + " not found");
                } else {
                  //map.setCenter(point, 13,G_HYBRID_MAP);
                  var marker = new GMarker(point);
                  GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(address);});
                  map.addOverlay(marker);
                  gmarkers[j] = marker
                  var lat = point.y;
                  var lng = point.x;
                  var spot = new GLatLng(lat,lng)
                  bounds.extend(spot)
                  //alert("Bounds = " + bounds + " j = " + j)
                  side_bar_html += '<a href="javascript:myclick(' + j
+ ')">' + address + '</a><br>';
                  //alert("Adding marker for " + address + " ,
side_bar_html= " + side_bar_html + " , j = " + j );
                  document.getElementById("side_bar").innerHTML =
side_bar_html;
                  marker.openInfoWindowHtml(address);
                }
              }
          );
     }

    function myclick(i){
        GEvent.trigger(gmarkers[i],"click");
    }

    function markTime(){
        for(i=0;i<10;i++){
            "just marking time counting to ten"
        }
    }

    //]]>
</script>
<body  onunload="GUnload()">
    <table>
        <tr>
            <td>
                <div id="map" style="width: 800px; height: 600px"></
div>
            </td>
            <td width="400" valign="top" style="text-
decoration:underline; color:Blue;">
                <div id="side_bar"></div>
            </td>
        </tr>
    </table>
    <table width="100%">
        <tr>
            <td align="right">
                Add new address markers here:
            </td>
            <td class="l_box_item">
                <asp:textbox id="txtAddress1" MaxLength="500"
Width="600" runat="server"></asp:textbox>
                <asp:button ID="btnSearch" runat="server"
Text="Search" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td class="l_box_item">
                <asp:TextBox ID="txtAddress2" MaxLength="500"
Width="600" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td class="l_box_item">
                <asp:TextBox ID="txtAddress3" MaxLength="500"
Width="600" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>

</body>
</asp:Content>
'*****END .aspx
************************************************************************

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to