Issue with CoronaViewer and Maps - no getAddressLocation, no addMarker

In regards to API access, I can’t seem to be able to properly use the Maps on CoronaViewer.

When I compile for Android the following simple example (taken from examples from CoronaLabs’YT channel) and install it as apk on my device, it works as expected. 

When I try to execute it via CoronaViewer, the map shows up centered in the ocean, and the marker is not positioned. I can scroll to the Eiffel Tower and find Google’s tooltip for it if I click on it.

Can somebody please help me in finding what’s wrong?

I did copy the required permissions from build.settings to CoronaViewer’s and compile it accordingly.

This is the simple map example code:

[lua]

myMap = native.newMapView(400, 600, 700, 1100)

local lat, long = myMap:getAddressLocation( “Eiffel Tower” ) – this doesn’t work

–local lat, long = 48.85815, 2.29452 – if I specify lat, long like this, map gets correctly centered

myMap:setCenter(lat, long) – this works when coords are hardwired

myMap:addMarker(lat, long, {title = “Big Tower”, subtitle = “It’s in France”}) – this doesn’t work

[/lua]

This is the current build.settings with which I compiled CoronaVIewer:

[lua]

settings =

{

orientation =

{

default = “portrait”,

supported = { “portrait” },

– supported = { “landscapeLeft”, “landscapeRight”, “portrait”, “portraitUpsideDown” },

},

plugins =

{

– key is the name passed to Lua’s ‘require()’

[“plugin.viewer”] =

{

– required

publisherId = “com.coronalabs”,

},

},

iphone =

{

plist =

{

CFBundleURLTypes =

{

{

CFBundleURLSchemes =

{

“db-l1q0pln8qsi8qyp”,

}

}

}

},

},

  android =

   {

    usesPermissions =

      {

        “android.permission.INTERNET”,

            --optional permission used to display current location via the GPS

            “android.permission.ACCESS_FINE_LOCATION”,

            --optional permission used to display current location via WiFi or cellular service

            “android.permission.ACCESS_COARSE_LOCATION”,

      },

      usesFeatures =

      {

            – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,

            – you may want to set up your app to not require location services as follows.

            – Otherwise, devices that do not have location sevices (such as a GPS) will be unable

            – to purchase this app in the app store.

            { name = “android.hardware.location”, required = false },

            { name = “android.hardware.location.gps”, required = false },

            { name = “android.hardware.location.network”, required = false }

      },

  },

}

[/lua]

This is the config.settings of my app, which makes the example work on my android device when compiled as apk and installed:

[lua]

settings =

{

    android =

    {

        usesPermissions =

        {

            “android.permission.INTERNET”,

            --optional permission used to display current location via the GPS

            “android.permission.ACCESS_FINE_LOCATION”,

            --optional permission used to display current location via WiFi or cellular service

            “android.permission.ACCESS_COARSE_LOCATION”,

        },

        usesFeatures =

        {

            – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,

            – you may want to set up your app to not require location services as follows.

            – Otherwise, devices that do not have location sevices (such as a GPS) will be unable

            – to purchase this app in the app store.

            { name = “android.hardware.location”, required = false },

            { name = “android.hardware.location.gps”, required = false },

            { name = “android.hardware.location.network”, required = false }

        },

    },

}

[/lua]

Many thanks!

Tried tinkering around with the build.settings, but no luck yet … it’s rather frustrating since I am trying to develop a location based app, and CoronaViewer is a huge help. Any help out there?

I’m not sure how well this will work or if locationServices works in the viewer environment (I would hope it would, but…).  Can you put together a simple app that demonstrates the issue and file a bug report? You probably will need to submit two zip files, one with your real project and one with the CoronaViewer project so we can see both build.settings files and use the Report a Bug link at the top of this page.

Engineering will be able to tell us if it’s supposed to work, and maybe suggest a combination of settings to make it work, but I can’t go to them without a bug report.

When you file the bug report you will get an email with the Bug case ID number in it. Please post it here, then I can ask engineering about it.

Rob

Hello Rob,
well, I can give the one I tried - the one above - in both versions, coronaviewer and apk. I can’t say I have a custom app because after a couple days trying to make the maps work, I concentrated my efforts on trying to do something similar to geofencing, and properly converting lat/lon to meters. Will put here the ID, thanks.

(On this last topic, not to put too much meat to cook on the same fire, but parameters to the relevant API are in metres but I see no quick way to measure distance travelled. Am I missing something re.metres<->latlng and geofencing, or maybe it’s been developed in some addon that I didn’t see?

Edit re.distances: I don’t know how I missed this post of yours: https://coronalabs.com/blog/2015/01/06/tutorial-calculating-the-distance-between-map-points/

Hi Rob,
case ID is 42067

Thanks

Hi max00,

In the sample you provided, you’re using a deprecated API: object:getAddressLocation().

Rewriting it to use object:getAddressLocation()'s replacement, object:requestLocation() and adding a resultHandler will allow your sample to work with CoronaViewer. See the revision below:

myMap = native.newMapView(400, 600, 700, 1100) local function locationHandler( event ) if ( event.isError ) then print( "Map Error: " .. event.errorMessage ) else print( "The specified string is at: " .. event.latitude .. "," .. event.longitude ) myMap:setCenter( event.latitude, event.longitude ) myMap:addMarker( event.latitude, event.longitude, {title = "Big Tower", subtitle = "It's in France"} ) end end myMap:requestLocation( "Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France", locationHandler )

Fantastic, just tried it in CoronaViewer and works fine. Thanks! May I suggest adding an overlay over the youtube video warning that the API is deprecated and a link to this update?

Thanks again,

Max

Can you let me know which YouTube video?

Thanks

Rob

Sure, I had posted it on the bug report but not here …

https://www.youtube.com/watch?v=c_BMXSWfCsc

Actually, now that I look at it, it’s from a Corona SDK channel but probably not managed by you. If it’s like that, my apologies :slight_smile: and I’ll take upon me to post a comment there re. the deprecation linking it here

I’ve sent this to our video person to investigate and fix.

Thanks for bringing it to our attention.

Rob

Tried tinkering around with the build.settings, but no luck yet … it’s rather frustrating since I am trying to develop a location based app, and CoronaViewer is a huge help. Any help out there?

I’m not sure how well this will work or if locationServices works in the viewer environment (I would hope it would, but…).  Can you put together a simple app that demonstrates the issue and file a bug report? You probably will need to submit two zip files, one with your real project and one with the CoronaViewer project so we can see both build.settings files and use the Report a Bug link at the top of this page.

Engineering will be able to tell us if it’s supposed to work, and maybe suggest a combination of settings to make it work, but I can’t go to them without a bug report.

When you file the bug report you will get an email with the Bug case ID number in it. Please post it here, then I can ask engineering about it.

Rob

Hello Rob,
well, I can give the one I tried - the one above - in both versions, coronaviewer and apk. I can’t say I have a custom app because after a couple days trying to make the maps work, I concentrated my efforts on trying to do something similar to geofencing, and properly converting lat/lon to meters. Will put here the ID, thanks.

(On this last topic, not to put too much meat to cook on the same fire, but parameters to the relevant API are in metres but I see no quick way to measure distance travelled. Am I missing something re.metres<->latlng and geofencing, or maybe it’s been developed in some addon that I didn’t see?

Edit re.distances: I don’t know how I missed this post of yours: https://coronalabs.com/blog/2015/01/06/tutorial-calculating-the-distance-between-map-points/

Hi Rob,
case ID is 42067

Thanks

Hi max00,

In the sample you provided, you’re using a deprecated API: object:getAddressLocation().

Rewriting it to use object:getAddressLocation()'s replacement, object:requestLocation() and adding a resultHandler will allow your sample to work with CoronaViewer. See the revision below:

myMap = native.newMapView(400, 600, 700, 1100) local function locationHandler( event ) if ( event.isError ) then print( "Map Error: " .. event.errorMessage ) else print( "The specified string is at: " .. event.latitude .. "," .. event.longitude ) myMap:setCenter( event.latitude, event.longitude ) myMap:addMarker( event.latitude, event.longitude, {title = "Big Tower", subtitle = "It's in France"} ) end end myMap:requestLocation( "Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France", locationHandler )

Fantastic, just tried it in CoronaViewer and works fine. Thanks! May I suggest adding an overlay over the youtube video warning that the API is deprecated and a link to this update?

Thanks again,

Max

Can you let me know which YouTube video?

Thanks

Rob

Sure, I had posted it on the bug report but not here …

https://www.youtube.com/watch?v=c_BMXSWfCsc

Actually, now that I look at it, it’s from a Corona SDK channel but probably not managed by you. If it’s like that, my apologies :slight_smile: and I’ll take upon me to post a comment there re. the deprecation linking it here

I’ve sent this to our video person to investigate and fix.

Thanks for bringing it to our attention.

Rob