简体   繁体   English

将Subgurim GMap坐标转换为字符串

[英]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 . 我已经开始将Subgurim's Map控件用于ASP.NET并且需要将coordinates转换为string或类似内容,以便可以将其放入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' 我对该sub的最后两行有Gmap1's placemarker's coordinates ,我将'coordinates'定义为Gmap1's placemarker's coordinates的结果,但是尽管在debugging过程中, GeoCode.Placemark.coordinates的值到'coordinates'

Here is a screenshot of the debugging process : http://www.wherelionsroam.co.uk/debug.png 这是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. 首先,如果调用GMap1.getGeoCodeRequest()并将GLatLng对象作为参数传递,则将浪费地理编码调用,因为返回的坐标与您作为参数传递的坐标相同。 Actually, in you code you have all you need in GeoCode.Placemark.coordinates . 实际上,在您的代码中,您拥有GeoCode.Placemark.coordinates所需的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). 您在lat变量中将具有latlng属性以及所需的信息,并保存一个地理编码调用(保存调用很重要,因为它们受Google的限制)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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