Mapview on Android

It’s available to paying customers now via our daily build system.

Or you can wait for our next release of the Corona SDK. We have not decided on a release date yet, but we might release early so that everyone can test drive a version that fully supports iOS 6 and the iPhone 5. [import]uid: 32256 topic_id: 31115 reply_id: 125159[/import]

Ok, thanks a lot. Will it be possible to program for the Android device in the next release or will that stay limited to paying customers for a quite a while ? [import]uid: 126207 topic_id: 31115 reply_id: 125161[/import]

Yes, you can code for your Android device “today” will the current release version. The only reason it is crashing on you is because [lua]native.newMapView()[/lua] is returning nil and you are making calls on a nil object. Just get rid of that code and your app will work fine. In fact, if you look at the Android log via the Android SDK “adb logcat” or “ddms” tools, then it will clue you in where it is going wrong. [import]uid: 32256 topic_id: 31115 reply_id: 125172[/import]

Joshua and mpappas, I wanted to thank you both for your help! I tried both of your approaches and was successful with each one! Each approach takes about the same amount of time (personal observation) to obtain GPS coordinates. Thanks again for all your help! [import]uid: 85963 topic_id: 31115 reply_id: 126028[/import]

Joshua and mpappas, I wanted to thank you both for your help! I tried both of your approaches and was successful with each one! Each approach takes about the same amount of time (personal observation) to obtain GPS coordinates. Thanks again for all your help! [import]uid: 85963 topic_id: 31115 reply_id: 126028[/import]

hello everybody

i need help with a problem with the marker for the map.

In my app I made a network request to get informations from a database like name, street, latitude and longitude and put them into an array. After the map has loaded in the way joshua descriped it i will set marker on the map. I tried to do this in this way but it doesn´t work he sets no markers:

[lua]for mark=1, w-1 do
markerlatitude = array[mark].latitude
markerlongitude = array[mark].longitude
markerTitle = array[mark].name
markerSubtitle = array[mark].street

– Add a pin to the map at the new location
myMap:addMarker( markerlatitude, markerlongitude, { title=markerTitle, subtitle=markerSubtitle } )
end[/lua]

Can anybody help it is very urgent. Thanks for any answer! [import]uid: 149464 topic_id: 31115 reply_id: 128344[/import]

Not sure what your “w” variable is set to but I always use the “#array” as my end of array variable. The sample snippet below is patterned after an app that works for me where I have previously stored the lat and long in their own arrays. Hope this helps! Scott

for mark=1,#latArray do myMap:addMarker(tonumber(latArray[mark]), tonumber(lngArray[mark]), {title=markerTitle, subtitle=markerSubtitle}) end [import]uid: 85963 topic_id: 31115 reply_id: 128401[/import]

No it doesn´t work he does´t set marker at all [import]uid: 149464 topic_id: 31115 reply_id: 128418[/import]

The [lua]addMarker()[/lua] function definitely works. Our sample app that is included with the Corona SDK proves it.

I suggest that you add a [lua]print()[/lua] function just before your [lua]addMarker()[/lua] call and print the variables that you are passing into it to verify that your variables are set to what you think they are. I suspect the variables are set to something invalid. You’ll then need to look at the Android log via “adb logcat” or “ddms” to look at the print output… and keep an eye out for any errors Corona might be outputting due to invalid parameters.

Remember that the latitude and longitude arguments must be numbers, not strings or nil. [import]uid: 32256 topic_id: 31115 reply_id: 128452[/import]

hello everybody

i need help with a problem with the marker for the map.

In my app I made a network request to get informations from a database like name, street, latitude and longitude and put them into an array. After the map has loaded in the way joshua descriped it i will set marker on the map. I tried to do this in this way but it doesn´t work he sets no markers:

[lua]for mark=1, w-1 do
markerlatitude = array[mark].latitude
markerlongitude = array[mark].longitude
markerTitle = array[mark].name
markerSubtitle = array[mark].street

– Add a pin to the map at the new location
myMap:addMarker( markerlatitude, markerlongitude, { title=markerTitle, subtitle=markerSubtitle } )
end[/lua]

Can anybody help it is very urgent. Thanks for any answer! [import]uid: 149464 topic_id: 31115 reply_id: 128344[/import]

Not sure what your “w” variable is set to but I always use the “#array” as my end of array variable. The sample snippet below is patterned after an app that works for me where I have previously stored the lat and long in their own arrays. Hope this helps! Scott

for mark=1,#latArray do myMap:addMarker(tonumber(latArray[mark]), tonumber(lngArray[mark]), {title=markerTitle, subtitle=markerSubtitle}) end [import]uid: 85963 topic_id: 31115 reply_id: 128401[/import]

No it doesn´t work he does´t set marker at all [import]uid: 149464 topic_id: 31115 reply_id: 128418[/import]

I have tried the script with tonumber so that i could be sure about that the variable is a number. but he doesn´t show me any marker.

i don´t know why it doesn´t work because i used the same script for the iphone app and it works very fine but on android i first has to change the way the map is loaded because the other way makes the app crash and if i write it like the way in this blog i can open the map it is loaded but the marker weren´t set. the strange think at this point is that i used the map like above to make a list where the distances are calculated and there it works well with the database request and the calculation of the values in the array but not with the google map.

before i used the javascript function to load the map and there he has no problems by setting the markers but he doesn´t get the current position. so i used the location handler function but it doesn´t work too. than i tried to use the map in the way like above to get the current position and to load this position into the javascript map but it crashes because the current position isn´t given correctly to the javascript map. what i do won´t work.

if i try to run the app in the android sdk it crashes when i would open it and it says that the app is stopped. i used the android sdk for the first time maybe i did something wrong there i don´t know but i tested the app on my htc before so that i haven´t to use the sdk. [import]uid: 149464 topic_id: 31115 reply_id: 128537[/import]

If your app is crashing, then have a look at the Android log via “adb logcat” or “ddms” to see what exactly is going wrong. There are no known crashers in the Android version of MapView. It’s proven to be quite solid. Odds are, you are missing some error handling when attempting to retrieve current location before the GPS has acquired your current location. Android takes much longer to acquire current position compared to iOS.

I also recommend that you try testing our sample app “Interface/MapView” that is included with the Corona SDK on your Android device. That sample app has been proven to work. Verify that markers and all of the button functionality work as well. Also notice that there is a lot of error handling already in that sample code. You’ll want to follow that example.

From there, I recommend that you add a lit bit of your functionality to that sample app. The idea is to verify your code on an app that has been proven to work on an Android device.
[import]uid: 32256 topic_id: 31115 reply_id: 128556[/import]

The [lua]addMarker()[/lua] function definitely works. Our sample app that is included with the Corona SDK proves it.

I suggest that you add a [lua]print()[/lua] function just before your [lua]addMarker()[/lua] call and print the variables that you are passing into it to verify that your variables are set to what you think they are. I suspect the variables are set to something invalid. You’ll then need to look at the Android log via “adb logcat” or “ddms” to look at the print output… and keep an eye out for any errors Corona might be outputting due to invalid parameters.

Remember that the latitude and longitude arguments must be numbers, not strings or nil. [import]uid: 32256 topic_id: 31115 reply_id: 128452[/import]

I have tried the script with tonumber so that i could be sure about that the variable is a number. but he doesn´t show me any marker.

i don´t know why it doesn´t work because i used the same script for the iphone app and it works very fine but on android i first has to change the way the map is loaded because the other way makes the app crash and if i write it like the way in this blog i can open the map it is loaded but the marker weren´t set. the strange think at this point is that i used the map like above to make a list where the distances are calculated and there it works well with the database request and the calculation of the values in the array but not with the google map.

before i used the javascript function to load the map and there he has no problems by setting the markers but he doesn´t get the current position. so i used the location handler function but it doesn´t work too. than i tried to use the map in the way like above to get the current position and to load this position into the javascript map but it crashes because the current position isn´t given correctly to the javascript map. what i do won´t work.

if i try to run the app in the android sdk it crashes when i would open it and it says that the app is stopped. i used the android sdk for the first time maybe i did something wrong there i don´t know but i tested the app on my htc before so that i haven´t to use the sdk. [import]uid: 149464 topic_id: 31115 reply_id: 128537[/import]

If your app is crashing, then have a look at the Android log via “adb logcat” or “ddms” to see what exactly is going wrong. There are no known crashers in the Android version of MapView. It’s proven to be quite solid. Odds are, you are missing some error handling when attempting to retrieve current location before the GPS has acquired your current location. Android takes much longer to acquire current position compared to iOS.

I also recommend that you try testing our sample app “Interface/MapView” that is included with the Corona SDK on your Android device. That sample app has been proven to work. Verify that markers and all of the button functionality work as well. Also notice that there is a lot of error handling already in that sample code. You’ll want to follow that example.

From there, I recommend that you add a lit bit of your functionality to that sample app. The idea is to verify your code on an app that has been proven to work on an Android device.
[import]uid: 32256 topic_id: 31115 reply_id: 128556[/import]

You can’t add markers directly after creating the map object on Android as you can on Iphone. Some devices will just show no markers at all, or just a few of them. On Android, you must add them in a callback function called 6 seconds later.

You can’t add markers directly after creating the map object on Android as you can on Iphone. Some devices will just show no markers at all, or just a few of them. On Android, you must add them in a callback function called 6 seconds later.