ASP.NET中的Google Maps问题 [英] Problem with Google Maps in ASP.NET

查看:80
本文介绍了ASP.NET中的Google Maps问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的asp.net项目上集成google maps,当我将其转换为c#时,这给了我这2个错误.

感谢您的帮助.

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);

推荐答案

好吧,第一个错误很容易纠正,请使用方括号通过其字符串键访问项目的索引:
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"]



第二个错误,虽然据我所知,但我不知道用于包装Google API对象的库是否足够了解如何解决它.它告诉您直接使用库类型而不是已创建对象的方法.因此,请尝试以下操作:



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.


这篇关于ASP.NET中的Google Maps问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆