Click here to Skip to main content
15,906,335 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

I created a broser that navigates to google maps when the
address etc. is typed in. It was working fine and then
started gining me an error:

"The requested site is unavailible or cannot be found"

Please any help would be appriciated

Here is the code I used

private void LoadMap()
        {
            int yCurrRow = dgvMeterDetails.CurrentRow.Index;

            strProvince = dgvMeterDetails["Province", yCurrRow].Value.ToString();
            strCity = dgvMeterDetails["City", yCurrRow].Value.ToString();
            strSuburb = dgvMeterDetails["Suburb", yCurrRow].Value.ToString();
            strStreetName = dgvMeterDetails["StreetName", yCurrRow].Value.ToString();
            strStreetNo = dgvMeterDetails["StreetNo", yCurrRow].Value.ToString();

            DataTable dt = new DataTable();

            try
            {
                StringBuilder OpenMap = new StringBuilder();
                OpenMap.Append("http://maps.googleapis.com/maps/api/staticmap?center=" + strProvince + "," + strCity + "," + strSuburb + "," + strStreetName + "," + strStreetNo + "&zoom=14&size=400x400&sensor=false");

                wbMap.Navigate(OpenMap.ToString());
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Unable To Load Web Browser");
            }
        }
Posted
Comments
Herman<T>.Instance 22-Feb-12 10:37am    
The requested site is unavailible or cannot be found --> did you check the url in line http://maps.googleapis.com/maps/api/staticmap. That the URL still leads to data
BobJanova 22-Feb-12 10:45am    
Did your network connection go down? Did Google Maps go down?
Ben Paxton 22-Feb-12 11:47am    
No it did not go down. I tested it a couple of times

1 solution

At first, you incorrectly use StringBuilder. This class was created to avoid recreating string objects in heap. So instead of "+" you should use Append method. But actually I recommend you to use String.Format here, here is example:
C#
String.Format("http://maps.googleapis.com/maps/api/staticmap?center={0},{1},{2},{3},{4}&zoom=14&size=400x400&sensor=false", strProvince, strCity, strSuburb, strStreetName, strStreetNo)


Regarding error, it is what it says. So if site is unavailable via your url this means that site is unavailable. Compare originally created URL with yours.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900