Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Create a zip code icon and a house icon.
If Not Page.IsPostBack Then
Dim zipicon As New GoogleIcon( _
"zip", _
"http://www.yourdomain.com/images/zip.png", _
New GoogleSize(20, 20), _
New GooglePoint(10, 10), _
New GooglePoint(10, 10) _
)
GoogleMap.Icons.Add(zipicon)
Dim houseicon As New GoogleIcon( _
"house", _
"http://www.yourdomain.com/images/house.png", _
New GoogleSize(20, 20), _
New GooglePoint(10, 10), _
New GooglePoint(10, 10) _
)
GoogleMap.Icons.Add(houseicon)
'Get all relevant zip codes.
'In this example I presume that you have a view in your database that joins two tables.
'One table holds the real estate listings and the other holds zip codes and their locations.
'The two tables are joined by the zipcode field.
Dim qryZip As String = "SELECT DISTINCT zipcode, ziplatlng " & _
"FROM vue_RealEstateZip " & _
"WHERE price BETWEEN @minprice AND @maxprice"
Dim cmd As New SqlCommand(qryZip, conn)
cmd.Parameters.AddWithValue("@minprice", 100)
cmd.Parameters.AddWithValue("@maxprice", 200)
conn.Open()
Dim dtr As SqlDataReader = cmd.ExecuteReader()
While dtr.Read()
Dim zipmarker As New GoogleMarker()
zipmarker.ID = dtr("zipcode").ToString
zipmarker.Point = GoogleLatLng.FromSqlLatLng(dtr("ziplatlng"))
'If not using the SqlLatLng UDT you may have to create the GoogleLatLng from other columns.
zipmarker.Options.Icon = GoogleMap.Icons(0)
'If we don't know the index position of the icon to use we can use the Find method
'zipmarker.Options.Icon = GoogleMap.Icons.Find(AddressOf GetIcon)
zipmarker.Options.Title = dtr("zipcode").ToString
'Finally we need to make the map react to clicks on the zip code markers.
zipmarker.ClientSideHandlers.OnClick = _
GoogleMap.CreateMapCallback(dtr("zipcode").ToString, False)
GoogleMap.Overlays.Add(zipmarker)
End While
dtr.Close()
conn.Close()
End If
End Sub
'Private Function GetIcon( icon as GoogleIcon) As Boolean
' If icon.ID = "zip" Then Return True Else : Return False
'End Function