首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Corona中添加Android标记

在Corona中添加Android标记
EN

Stack Overflow用户
提问于 2015-03-03 11:28:13
回答 1查看 829关注 0票数 0

我很难把记号笔加上去。(只在Android设备上尝试)我想在地图加载后立即添加标记。让它工作,添加一个延迟,但不能通过添加标记或重新缩放映射(通过使用setRegion)使其工作。

我尝试了以下几点:

1.

局部地图

代码语言:javascript
复制
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
  1. 这个是正确的
代码语言:javascript
复制
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得到的数字是正确的。

  1. 应用@AniV提交的溶液 本地尝试=0 mapa=native.newMapView( 20,20,280,360 ) mapa.x = display.contentCenterX mapa.y = display.contentCenterY mapa.mapType =“标准”地图:setCenter( 41.641208,-0.896030 ) mapa:setRegion(41.641208,-0.896030,0.01,0.01)mapa.isLocationVisible=true本地函数locationHandler(事件)本地currentLocation = myMap:getUserLocation() locationHandler=-0.896030 if ( currentLocation.errorCode或( currentLocation.latitude == 0和currentLocation.longitude == 0))然后尝试= then +1如果(尝试> 10 )那么native.showAlert(“没有GPS信号”,“无法与GPS同步”,{“de”}) timer.performWithDelay( 2000年,locationHandler ):setCenter( rinconEncinaLat,rinconEncinaLon )地图:addMarker( rinconEncinaLat,rinconEncinaLon,{ title = "El Rincon de la Encina",副标题= "Ofertas diarias!“)结束locationHandler()

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2015-03-03 23:37:53

一种解决方案是反复对位置硬件排队,直到接收到适当的响应为止,然后调用此函数。有关详细信息,请参阅对象:getUserLocation()中的示例。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28830686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档