簡體   English   中英

將Subgurim GMap坐標轉換為字符串

[英]Converting Subgurim GMap Coordinates to string

我已經開始將Subgurim's Map控件用於ASP.NET並且需要將coordinates轉換為string或類似內容,以便可以將其放入database

這是我的代碼:

  Protected Sub lnkShowMap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkShowMap.Click Dim strFullAddress As String Dim sMapKey As String = ConfigurationManager.AppSettings("googlemaps.subgurim.net") Dim GeoCode As 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) Dim gLatLng As New Subgurim.Controles.GLatLng(GeoCode.Placemark.coordinates.lat, GeoCode.Placemark.coordinates.lng) ' Display the map GMap1.setCenter(gLatLng, 16, Subgurim.Controles.GMapType.GTypes.Normal) Dim oMarker As New Subgurim.Controles.GMarker(gLatLng) GMap1.addGMarker(oMarker) ' Create coordinates in stored mem ' Dim coordinates As GeoCode = GMap1.getGeoCodeRequest(GeoCode.Placemark.coordinates) System.Diagnostics.Debug.WriteLine(coordinates) End Sub 

我對該sub的最后兩行有Gmap1's placemarker's coordinates ,我將'coordinates'定義為Gmap1's placemarker's coordinates的結果,但是盡管在debugging過程中, GeoCode.Placemark.coordinates的值到'coordinates'

這是debugging process的屏幕截圖: http : //www.wherelionsroam.co.uk/debug.png

我究竟做錯了什么?

首先,如果調用GMap1.getGeoCodeRequest()並將GLatLng對象作為參數傳遞,則將浪費地理編碼調用,因為返回的坐標與您作為參數傳遞的坐標相同。 實際上,在您的代碼中,您擁有GeoCode.Placemark.coordinates所需的GeoCode.Placemark.coordinates

Dim coordinates as GLatLng = GeoCode.Placemark.coordinates

您在lat變量中將具有latlng屬性以及所需的信息,並保存一個地理編碼調用(保存調用很重要,因為它們受Google的限制)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM