Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to integrate google maps ono my asp.net project and when I converted it to c# it gave me these 2 errors.

Thanks for any help.

string strFullAddress = null;
            string sMapKey = ConfigurationManager.AppSettings("googlemaps.subgurim.net");
            Subgurim.Controles.GeoCode GeoCode = default(Subgurim.Controles.GeoCode);

            // Combine our address fields to create the full address.  The street, suburb and country should be seperated by
            // periods (.)
            strFullAddress = txtStreetAddress.Text + ". " + txtSuburb.Text + ". " + txtCountry.Text;

            // Work out the longitude and latitude
            GeoCode = GMap1.geoCodeRequest(strFullAddress, sMapKey);            Subgurim.Controles.GLatLng gLatLng = new Subgurim.Controles.GLatLng(GeoCode.Placemark.coordinates.lat, GeoCode.Placemark.coordinates.lng);

            // Display the map
            GMap1.setCenter(gLatLng, 16, Subgurim.Controles.GMapType.GTypes.Normal);
            Subgurim.Controles.GMarker oMarker = new Subgurim.Controles.GMarker(gLatLng);
            GMap1.addGMarker(oMarker);
Posted
Updated 23-Aug-11 4:16am
v2
Comments
TheyCallMeMrJames 23-Aug-11 10:16am    
Can you update the body of your question to include the errors as well?
andilemtshali 23-Aug-11 10:36am    
the first code i underlined says "Non-invocable member'System.ConfigurationManager.AppSettings' cannot be used like method".
And the second underlined part says "Member'Subgruim.Controles.GeoCodeRequest(string, string)'cannot be accessed with an instance reference; qualify it with a type name instead"

1 solution

Okay the first error is easy enough to correct, use square brackets to access the index of an item by its string key:
ConfigurationManager.AppSettings["googlemaps.subgurim.net"]


The second error, while I understand it, I don't know the library used to wrap Google API objects well enough to know how to fix it. It's telling you to use the method directly off the library type, not of the object you've created. So try this instead:
GeoCode = Subgruim.Controles.geoCodeRequest(strFullAddress, sMapKey); 


Cheers.
 
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