Can Someone Confirm Getuserlocation() Works Using Storyboard? I'm Getting Zero For Lat And Long In My Ios Build Simulator

Need some help confirming getUserLocation works in storyboard. I was able to get it to work using a simple app but when I applied the same logic to an app using storyboard I get 0 values.

Troubleshooting Steps:

  • working using standalone app

  • printed out values using Corona simulator and lat and long values are 37/-122

  • confirmed iOS simulator location set to custom location

Build: 1076

Thanks in advance!

No reason why it shouldn’t work, so long as you are either storing the response in a global variable or saving it to disk and retrieving it in each scene using a data storage library such as GGData or DMC AutoStore.

my app is more simple than that in that the map view occurs in one scene file. i did some more testing and can see that my lat/long variables get over written to ‘0’ after it uses getUserLocation. i initialized variables to ‘1’ in the enterScene and wrote an alert before and after getUserLocation.

Has anybody else used getUserLocation along with storyboard? I know it should be straight forward but I’ve confirmed bugs in the past after spending precious hours troubleshooting. Here is my code…

 

local  myMap

local myLat

local myLong

local myLocation

local myOptions

 

function scene:createScene( event )

    local group = self.view

 

    myMap = native.newMapView(0, 65, display.contentWidth, 385 - top)

    myMap.mapType = “normal”

    myMap.alpha = 1   

    myLocation = myMap:getUserLocation()

    myLat = myLocation.latitude

    myLong = myLocation.longitude  

    myOptions = { title = “Lat:”…myLat…"/Long:"…myLong, subtitle = “You are here!” }

    print("myLat = "…myLat) –> Corona Simulator: 37

    print("myLong = "…myLong)  –> ** Corona Simulator: ** -122 

    native.showAlert( "My Lat/Long: “, myLat…” / "…myLong )  –>   iOS Simulator: 0/0

    myMap:addMarker( myLat, myLong, myOptions)

    myMap:setCenter( myLat, myLong)

end

Ok…stupid mistake. I found out when you build for iOS the first time it will ask if you want <application name> to use your current location. It does this the first time and never ask you again if you keep building using the same application name. I used a default application name continuously and forgot I clicked ‘Don’t Allow’ when prompted.

No reason why it shouldn’t work, so long as you are either storing the response in a global variable or saving it to disk and retrieving it in each scene using a data storage library such as GGData or DMC AutoStore.

my app is more simple than that in that the map view occurs in one scene file. i did some more testing and can see that my lat/long variables get over written to ‘0’ after it uses getUserLocation. i initialized variables to ‘1’ in the enterScene and wrote an alert before and after getUserLocation.

Has anybody else used getUserLocation along with storyboard? I know it should be straight forward but I’ve confirmed bugs in the past after spending precious hours troubleshooting. Here is my code…

 

local  myMap

local myLat

local myLong

local myLocation

local myOptions

 

function scene:createScene( event )

    local group = self.view

 

    myMap = native.newMapView(0, 65, display.contentWidth, 385 - top)

    myMap.mapType = “normal”

    myMap.alpha = 1   

    myLocation = myMap:getUserLocation()

    myLat = myLocation.latitude

    myLong = myLocation.longitude  

    myOptions = { title = “Lat:”…myLat…"/Long:"…myLong, subtitle = “You are here!” }

    print("myLat = "…myLat) –> Corona Simulator: 37

    print("myLong = "…myLong)  –> ** Corona Simulator: ** -122 

    native.showAlert( "My Lat/Long: “, myLat…” / "…myLong )  –>   iOS Simulator: 0/0

    myMap:addMarker( myLat, myLong, myOptions)

    myMap:setCenter( myLat, myLong)

end

Ok…stupid mistake. I found out when you build for iOS the first time it will ask if you want <application name> to use your current location. It does this the first time and never ask you again if you keep building using the same application name. I used a default application name continuously and forgot I clicked ‘Don’t Allow’ when prompted.

Hey guys, even with allowing the application to use access location services, it still returns 0,0 on Sim and Device for me. Any ideas? This is for iOS only using public build 2189. 

Hey guys, even with allowing the application to use access location services, it still returns 0,0 on Sim and Device for me. Any ideas? This is for iOS only using public build 2189.