views:

177

answers:

0

Hi,

I am having a problem with google traffic maps in a usercontrol.I have a usercontrol which has google traffic map with a Zip Code textbox, Search and Clear link buttons. The problem with this usercontrol it displays map with the traffic for on page load(with default zip) but when I try to search for a zip and click search link button it doesnt display map at all. I am calling the javascript on load as well as button click event to display google traffic. I even tried setting the visibility of the div no luck.

Please find the code below.

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="GoogleTraffic.ascx.vb" Inherits="mycounty_webparts_GoogleTraffic" %>

function gload() { var map; var geocoder; var trafficInfo; var address=document.getElementById('').value; map = new GMap2(document.getElementById("map")); geocoder = new GClientGeocoder(); alert(address); geocoder.getLatLng(address, function(point) { alert(point); if(!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var trafficOptions = {incidents:true}; //alert(trafficOptions); trafficInfo = new GTrafficOverlay(trafficOptions); //alert(trafficInfo); map.addOverlay(trafficInfo); } }); } Search Clear

Imports System.Web Imports System Imports System.IO Imports System.Net Imports System.Text Imports System.Xml Imports System.Configuration Imports Subgurim.Controles Partial Class mycounty_webparts_GoogleTraffic Inherits System.Web.UI.UserControl Dim objWCPC As New CountyProfileCommon(System.Configuration.ConfigurationManager.AppSettings("loginemail"))

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    lnkSearch.Attributes.Add("onclick", "gload();")

    If Not Page.IsPostBack Then

        If ConfigurationManager.AppSettings("loginid") = "" Or _
            ConfigurationManager.AppSettings("loginid") Is Nothing Or _
            ConfigurationManager.AppSettings("loginemail") = "" Or _
            ConfigurationManager.AppSettings("loginemail") Is Nothing Or _
            objWCPC.TrafficZipCode = "" Or objWCPC.TrafficZipCode Is Nothing Then
            txtZip.Text = "48226"
        Else
            txtZip.Text = objWCPC.TrafficZipCode
        End If
     Page.ClientScript.RegisterStartupScript(Me.GetType(), "loadMap", "gload();", True)

        End If
        End Sub

Protected Sub lnkClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkClear.Click
    objWCPC.TrafficZipCode = ""
    txtZip.Text = ""
End Sub

Any help would be greatly appreciated as I am new to Gmaps

Thanks and Regards, Nikky