corona sdk android,在Corona SDK中为Android添加标记

我无法添加标记。 (仅在Android设备上尝试过)我想在加载地图后立即添加标记。得到它的工作增加了延迟,但不能通过添加标记或再次缩放地图来使其工作(使用setRegion)。在Corona SDK中为Android添加标记

我试过如下:

1.

当地地图

mapa=native.newMapView(20, 20, 280, 360)

mapa.x = display.contentCenterX

mapa.y = display.contentCenterY

mapa.mapType = "standard"

mapa:setCenter(41.641208, -0.896030)

mapa:addMarker(tonumber(41.641208), tonumber(-0.896030),{

title = "El Rincon de la Encina",

subtitle = "Ofertas diarias!"})

mapa:setRegion(41.641208, -0.896030, 0.01, 0.01, false)

mapa.isLocationVisible=true

2.这一个正常工作

local mapa

mapa=native.newMapView(20, 20, 280, 360)

mapa.x = display.contentCenterX

mapa.y = display.contentCenterY

mapa.mapType = "standard"

mapa:setCenter(41.641208, -0.896030)

mapa.isLocationVisible=true

local function listener:timer(event)

mapa:addMarker(tonumber(41.641208), tonumber(-0.896030),{

title = "El Rincon de la Encina",

subtitle = "Ofertas diarias!"})

end

timer.performWithDelay(30000, listener)

只有当计时器后,调用函数地图加载我得到想要的结果。

添加tonumber的原因是为了确保Corona正确地得到了编号。

施加由@AniV

本地尝试= 0 mapa=native.newMapView(20, 20, 280, 360)

mapa.x = display.contentCenterX

mapa.y = display.contentCenterY

mapa.mapType = "standard"

mapa:setCenter(41.641208, -0.896030)

mapa:setRegion(41.641208, -0.896030, 0.01, 0.01, false)

mapa.isLocationVisible=true

local function locationHandler(event)

local currentLocation = myMap:getUserLocation()

local rinconEncinaLat = 41.641208

local rinconEncinaLon=-0.896030

if (currentLocation.errorCode or (currentLocation.latitude == 0 and currentLocation.longitude == 0)) then

attempts = attempts + 1

if (attempts > 10) then

native.showAlert("No GPS Signal", "Can't sync with GPS.", { "Okay" })

else

timer.performWithDelay(2000, locationHandler)

end

else

mapa:setCenter(rinconEncinaLat, rinconEncinaLon)

mapa:addMarker(rinconEncinaLat, rinconEncinaLon,{

title = "El Rincon de la Encina",

subtitle = "Ofertas diarias!"})

end

end

locationHandler()

感谢您的帮助移交该溶液中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值