Google maps 电晕-通过lat,长变量至setcenter和addmarker不工作
这个问题与使用map api函数setcenter和addmarker在Corona(lua)中将变量数据作为地图坐标(lat,long)传递有关 我在让mapview-setcenter和addmarker识别lat、long变量时遇到问题。如果有人能提出任何建议,我将不胜感激。很难诊断,因为我必须在设备上加载apk进行测试,我无法看到错误 什么有效 此代码在设备上运行正常:Google maps 电晕-通过lat,长变量至setcenter和addmarker不工作,google-maps,lua,coronasdk,Google Maps,Lua,Coronasdk,这个问题与使用map api函数setcenter和addmarker在Corona(lua)中将变量数据作为地图坐标(lat,long)传递有关 我在让mapview-setcenter和addmarker识别lat、long变量时遇到问题。如果有人能提出任何建议,我将不胜感激。很难诊断,因为我必须在设备上加载apk进行测试,我无法看到错误 什么有效 此代码在设备上运行正常: myMap:setCenter( 30.192729,-81.364483 ) local function map
myMap:setCenter( 30.192729,-81.364483 )
local function mapmarker( event )
myMap:addMarker( 30.192729,-81.364483 )
end
timer.performWithDelay( 10000, mapmarker)
仅供参考:我必须添加延迟以给地图加载标记的时间,否则它不会在设备上显示标记
什么不起作用
现在,如果我用变量替换实际的lat,long数字,它将不起作用。地图视图仍然有效,但默认为我当前的操作
local currentXlatitude = tonumber(decodedData[2])
local currentXlongitude = tonumber(decodedData[3])
local location = (currentXlatitude.."," ..currentXlongitude)
1) 当我将这些变量打印到控制台时,它们保存的是有效的数字
print (currentXlatitude)
print (currentXlongitude)
30.192729
-81.364483
2) 此外,我通过将变量传递到映射url来测试这些变量,它们工作得很好。
mapURL=“”…位置
3) 为了确定,我将变量设置为实际数字,但这也不起作用
local currentXlatitude = 30.192729
local currentXlongitude = -81.364483
4) 下面是带有变量“location”的代码。在设备上,地图默认为我的位置,没有标记
myMap:setCenter( location )
local function mapmarker( event )
myMap:addMarker( location )
end
timer.performWithDelay( 10000, mapmarker)
5) 我还尝试了以下方法。设备上的结果相同,默认为“我的位置”
myMap:setCenter( currentXlatitude..","..currentXlongitude)
local function mapmarker( event )
myMap:addMarker( currentXlatitude..","..currentXlongitude)
end
timer.performWithDelay( 10000, mapmarker)
6) 我还尝试了变量的“”和“”
7) 最后一件事,我试着给设置中心增加一个延迟,但也不起作用
local currentXlatitude = 30.192729
local currentXlongitude = -81.364483
提前感谢所有能够提供建议的人。您必须使用单独的函数调用参数:
local function mapmarker( event )
myMap:addMarker( currentXlatitude, currentXlongitude)
end
谢谢Scholli,我也尝试了你建议的格式,但不起作用。还有其他建议吗?