我无法添加标记。 (仅在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()
感谢您的帮助移交该溶液中。