I have been having problems with mapview. I have distilled my page to the following very simple code, basically the same as the description for newmapview in the docs; I have replicated the entire file (altMapView.lua) below:
module(…, package.seeall)
–local widget = require “widget”
local CS = require(“CommonSubroutines”)
local groupedStuff = require (“GroupedStuff”)
local director = require (“director”)
local blueColor = { 0, 0, 255, 255 }
local blackColor = { 0, 0, 0, 255 }
–FUNCTIONS
new = {}
function new()
local localGroup = display.newGroup()
local background = display.newImage (“Images/MBF_idea1wordsonly_flat.png”)
localGroup:insert(background)
– Create a native MapView (requires XCode Simulator build or device build)
– You can create multiple maps, if you like…
– this segment causes the crash on actual android device, from here to setcenter
myMap = native.newMapView( 20, 20, 280, 220 )
myMap.mapType = “standard” – other mapType options are “satellite” or “hybrid”
– The MapView is just another Corona display object, and can be moved or rotated, etc.
myMap.x = display.contentWidth / 2
myMap.y = 120
– Initialize map to a real location, since default location (0,0) is not very interesting
myMap:setCenter( 37.331692, -122.030456 )
local BackButton = CS.seftNewButton{
sourceImage = “Images/MusicButton.png”, – button pix name in Images/ folder
sourceImageOnOver = “Images/buttonBlue.png”, – mouseover button pix name in Images/ folder
btnText = “Menu”, – text to display on button (need font too?")
textColor = blackColor,
size = 12,
–xPos = 100,
–fred = display.screenOriginX
–yPos = 420, – y pos of button
xPos = localGroup.contentWidth/2, – x pos of button
yPos = (display.viewableContentHeight-25),
–onTap = xxx – eventListener (maybe not in this function)
}
localGroup:insert(BackButton) – add the button to the group
function BackButtonPressed (event)
if event.phase == “ended” then
director:changeScene (“menu”)
end – end if eventphase be ‘ended’
end – end local fcn backbuttonpressed
BackButton:addEventListener (“touch”, BackButtonPressed)
return localGroup
end – end function new
It works fine on my iPhone 4S, but on the Android device it does not work at all. When I go to this page I get the following:
Director Class - Error
Director Error - failed to execute new (params) function on ‘mapscreen’.
this error occurs in various builds including 1033, 1038 and 1050.
Any ideas? [import]uid: 31397 topic_id: 37560 reply_id: 67560[/import]