0

我已经开始使用Subgurim's Map控件,ASP.NET并且需要将其转换coordinates为 astring或类似的东西,以便我可以将其放入我的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,我将其定义'coordinates'为 的结果Gmap1's placemarker's coordinates,但尽管在此期间debugging, 的值GeoCode.Placemark.coordinates并未归因于'coordinates'

这是一个截图debugging process: http: //www.wherelionsroam.co.uk/debug.png

我究竟做错了什么?

4

1 回答 1

1

首先,如果您调用GMap1.getGeoCodeRequest()GLatLng对象作为参数传递,您将浪费地理编码调用,因为返回的坐标将与您作为参数传递的坐标相同。实际上,在您的代码中,您拥有所需的一切GeoCode.Placemark.coordinates

Dim coordinates as GLatLng = GeoCode.Placemark.coordinates

在坐标变量中,您将拥有latlng属性,其中包含您需要的信息并保存一个地理编码调用(保存调用很重要,因为它们受到 Google 的限制)。

于 2013-04-13T09:22:23.340 回答