通过Wifi或蜂窝信号获取位置的方法,Corona SDK 可以实现。

我遇到了一个大问题,我有点烦恼于有多少关于 getUserLocation() 的信息,却一个都没用。我只需要通过蜂窝或 wifi 获取经纬度,不需要其他任何信息,如果有比 getUserLocation 更好的方式,我也可以接受。

当我在手机上运行此代码时,它会显示 当前位置未知。

myMap = native.newMapView( 20, 20, 300, 220 )
function callMap()
  if(myMap ~= nil) then
    local currentLocation = myMap:getUserLocation()

    if currentLocation.errorCode ~= nil then
      native.showAlert("天哪,它又不工作了",
                       currentLocation.errorMessage, {"确定"})
    else
      native.showAlert("errorCode 是 nil,这是好的","...", {"确定"})
    end
  else
      native.showAlert("地图是 nil", "...", {"确定"})
  end
end

timer.performWithDelay( 3000, callMap )
点赞
用户3284364
用户3284364

将下面翻译成中文并且保留原本的 markdown 格式

Okay so the problem was that my phone didn't have set up reaching position by Wifi or Cellular, thats it :D it was really easy.

好的,问题就是我的手机没有设置通过 Wi-Fi 或蜂窝网络获取位置,就是这样 :D ,这真的很容易。

2014-04-28 18:30:04