简体   繁体   中英

Converting Subgurim GMap Coordinates to string

I have started using Subgurim's Map controls for ASP.NET and need to convert the coordinates into a string or something similar so that I can put it in my database .

Here is my code:

  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 

I'm having a problem with the last two lines of this sub , I am defining 'coordinates' as being the result of Gmap1's placemarker's coordinates , but despite the fact that during debugging , the value of GeoCode.Placemark.coordinates is not being attributed to 'coordinates'

Here is a screenshot of the debugging process : http://www.wherelionsroam.co.uk/debug.png

What am I doing wrong?

First of all, if you call GMap1.getGeoCodeRequest() passing a GLatLng object as a parameter you will waste a geocoding call because the returned coordinates will be the same you passed as an argument. Actually, in you code you have all you need in GeoCode.Placemark.coordinates .

Dim coordinates as GLatLng = GeoCode.Placemark.coordinates

The in the coordinates variable you'll have the lat and lng properties with the information you need and saving one geocoding call (it's important to save calls because they are limited by Google).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM