我正在用windev mobile构建一个Android应用程序。我可以使用描述地址和城市的变量来打开地图,但我似乎无法以相同的方式在地图上获得标记。 ggladdresstocoordinates并不适用于windev mobile。
我目前的代码是:
//MapDisplayPosition(MAP_Worklocation, Street, City, country)
MyAddress is Address
MyAddress..Street = gnWorkaddress
MyAddress..City = gnWorkplace
MyAddress..Country = "Netherlands"
// Centers the map displayed by the "MAP_Position" control from an address
MapDisplayPosition(MAP_Worklocation, MyAddress)
MAP_Worklocation..Zoom = 17
mymarker is Marker
mymarker..Position = MyAddress
MapAddMarker(MAP_Worklocation, mymarker)
答案 0 :(得分:0)
使用MapDisplayPosition后,地图将居中于搜索位置,然后,如果您使用MapGetPosition,它将返回坐标。从Windev帮助:MapGetPosition-“返回当前在地图控件中显示的地图中心的点的地理位置。”
MyPosition is geoPosition
MyPosition = MapGetPosition(MAP_Worklocation)
EDT_Latitude=MyPosition..Latitude
EDT_Longitude=MyPosition..Longitude
答案 1 :(得分:0)
我认为问题出在MapDisplayPosition函数中,第二个参数必须是geoPostiion变量,如您所见in the help或它可能是带有地址的字符串,您是否尝试过:
sAddress is string = gnWorkaddress + ", " + gnWorkplace + ", " + "Netherlands"
MapDisplayPosition(MAP_Worklocation, sAddress)
此外,您无法将Address
分配给..Position
,而需要geoPosition变量;使用MapDisplayPosition将地图居中后,您可以使用以下方法检索位置:
TmpPos is geoPosition
TmpPos = MapGetPosition(MAP_Worklocation)
然后添加标记:
MyMarker is Marker
MyMarker..Position = TmpPos
MyMarker..ActionClick = ProcMarkerClick
MapAddMarker(MAP_Worklocation, MyMarker)
尝试一下,我个人发现了一个不同的解决方法,因为在注册过程中,发件人和地址(街道,邮政编码,城市...)都写了,我需要使用gps代码,所以我使用了Google Maps Apis:< / p>
oQuery is httpRequest
// Replace blank spaces with +, for URL.
sTempStreet is string = Replace(MyStreet," ","+")
sTempCity is string = Replace(MyCity," ","+")
oQuery..URL = "https://maps.googleapis.com/maps/api/geocode/json?address="+sTempStreet+",+"+sTempCity+"+"+stTempZIP+"+"+stTempCountry+",+stTempState&key=*<yourapikeyhere>*"
oQuery..Method = httpGet
oResponse is httpResponse
oResponse = HTTPSend(oQuery)
vInfo is Variant
vInfo = JSONToVariant(oResponse..Content)
sGPSLatitude = vInfo.results[1].geometry.location.lat
sGPSLongidute = vInfo.results[1].geometry.location.lng