App That Uses Maps API

Hey guys, I’ve been working on an app for some time now, and I’ve reached a roadblock at one of the main functionalities of the app.

I want my app to be able to locate other users (in real time) on a map, in order to set up meets or simply to see their location, similarly to how Find My Friends ios app does or the taxi app Uber does.

I was wondering if anyone has done anything like this before, or has any idea of how it can be done, and was willing to chat with me about it?

Thanks in advance

-YL

edit: I don’t think I emphasized the part of setting up meetings in a specific location (also forgot to mention users would be able to accept or decline the “meeting”) enough, as this is one of the main purposes for the app to use maps.

My initial thought would be that you would need to poll for the location periodically, and then post it to an online database by user ID.

Obviously you would have to handle frequency etc to prevent drain, and allow for security so people can’t locate strangers positions.

bump

Are you looking for someone to help with brainstorming and evaluation of Corona being the correct SDK for this app, or are you looking for someone to write actual code for you to use in this app?

I ask because if it’s the latter, you might be better posting the in “Corona Jobs” section.

This is still a pretty broad topic. Generally speaking

  1. Your app starts up and starts up location services. See: https://docs.coronalabs.com/api/event/location/index.html

  2. Upon startup, you won’t get a very accurate location because it’s getting from cellular or WiFi. It takes a bit to sync up with the GPS satellites in particular inside buildings. Once you get a location you would use a network.request() and post that location to your online database.

  3. You would then next do a query of your online database that says get me everyone within X distance. You want your server to process this if possible (assuming you have your own server to write PHP type scripts connecting to your local database). This will minimize data transmission, which is a goal for people on cellular connections. The online script could use some simple math to compute those within your desired range and return a table of data (JSON encoded) that has all the user info you need and their lat, long.

  4. Using the map from the Business App sample where it puts pins on the map for StarBucks locations, you simply use the table of people and add pins using the lat, long included in the table. You can put some information in the speech bubbles that show up. You can then setup a touch handler to goto another page to show more details, setup what you want and so on.

Rob

@Alex, Neither, I guess. I wanted to try to find someone whos worked on an app similar to this to ask some questions, like what backend they are using and that sort of thing.

@Rob Miracle, Since you mention a server, I was wondering if you knew of any particular server service that you would recommend, now that Parse Server is shutting down. I was originally using just a free webhosting server with mysql and php scripts, but then you mentioned something about push notifications in another topic which I dont think that server can do.

Using this method you mentioned, it would (from what I understood) just post one location, once, upon app startup. What if I wanted the location to be updated in real time, would this still be a viable method? My original thoughts were it would be too demandnig on the server and app, which would be constantly running network requests updating the database every X amount of seconds… Am I correct to think this? Is this why the other time (in a different topic) you suggested push notifications (I honestly dont know that much about push notifications other then used for sending messages to your users)?

Our currently recommended choice now is Coronium.io. Currently Coronium is being adapted to become Corona Cloud. Today, you have to self-host this. @Develephant provides two hosting options for simple installs. One is Amazon AWS. This is a pay as you use resources service, but you are cloud hosted. The other option is Digital Ocean which is a fixed per month fee.

The nice thing about Coronium is I think you have more power on the server side to do custom things like only find people withing a certain distance like you do. Parse was pretty much a data store and you were more limited on the server side scripting

As far as push notifications go, any old hosting with PHP can send automated push notifications. There was an old blog post that covered how to setup PHP to send push’s. Also there are several other push services out there. Big guys like Urban Airship and Pushwoosh have API’s to allow software to generate the messages and they send them but its not free. A popular choice for Corona Developers is to use OneSignal (see: https://documentation.onesignal.com/docs/corona-sdk-overview ).

Sending location updates as fast as you get GPS events would be too much. You could probably get away with updating once per minute. People don’t move that fast usually.

Pardon my ignorance, but using Coronium, what scripting language would I use? Or does it depend on the host, say for example AWS, would it be php?

And regarding another one of the functionalities of my app, how would I go implementing user to user contact? Say once i have the maps and location down, a user would want to send a request to another user that is nearby, is this done by user sends request to specific person to server - server sends push notification to receiving user - user agrees or declines - response is sent back to server - server sends push notification to first user with the response? Does this make sense or am i looking at this the wrong way?

bump

Coronium uses Lua as it’s scripting language!!!  Check it out: http://coronium.io/

Contacting other users would best be done via push notifications. Coronium can do your push notifications for you too. It can handle your login tracking. You’re on the right track with your thinking.

After some time setting up coronium and aws… I finally got it set up and running and was able to stfp to the server (i was having some troubles with the key pairs).

Do you have any prior experience with coronium? I ask you because i now have to migrate from my old server, and I honestly dont know if my php scripts will need any changes to work with coronium (i know its silly to ask this because how would you know without even seeing my php files)… I hope most of the changes will be in the client side… guess i wont be using network.request anymore

I don’t want to sound mean, but the question above has nothing to do with “App that uses maps API”. It’s now a question about Coronium. There is a specific forum for those questions that’s monitored by the Coronium creator @develphant. I only have a minuscule amount of experience with Coronium, basically enough to know its feature set.

So basically by asking here, the people who can answer your question will never see it. I would start a new question in the Coronium forum.

Thanks

Rob

Hey Rob,

You mentioned a blog post about php push notifications, I went on to look for it but the only one I could find was a post about “Easy APNS” which apparently is only for ios push notifications? Was this the one you meant?

edit: I was also going to ask you another thing on how to actually use push notifications to implement the functionality I wanted, but I figured you’d tell me to start a new topic. So here is a link to the new topic, in case you were willing to help me out:

https://forums.coronalabs.com/topic/62715-user-to-user-interaction-using-push-notifications/

Yes, that’s the post.

https://gyazo.com/77e16b4db3ad7fadf405717f8c4422bf

any ideas why this might be?

EDIT: forgot to mention, my map shows up as a grey box in the screen, but it never loads.

its initially set to center on current location from mymap.getuserlocation, then i have a text field thats supposed to center on what you search, also add a marker (like in the sample app)

figured you’d ask to see my code, so here it is:

local composer = require "composer" local scene = composer.newScene() local widget = require "widget" -- name all local variables here -- defined local (scene) functions here local titleBar, navBar, myMap, addressBar local attempts = 0 local function maplocationHandler( event ) local currentLocation = myMap:getUserLocation() 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( 1000, locationHandler ) end else myMap:setCenter( currentLocation.latitude, currentLocation.longitude ) myMap:setRegion( currentLocation.latitude, currentLocation.longitude ) local options = { title="You are here", } myMap:addMarker( currentLocation.latitude, currentLocation.longitude, options ) end end local function mapSearchLocationHandler(event) if ( event.isError ) then print( "Map Error: " .. event.errorMessage ) else myMap:setCenter( event.latitude, event.longitude, false ) myMap:setRegion( event.latitude, event.longitude, 0.25, 0.25, false) local options = { title=event.text, } myMap:addMarker( event.latitude, event.longitude, options ) end end local function addressBarHandler( event ) if event.phase == "began" then elseif event.phase == "ended" or event.phase == "submitted" then myMap:requestLocation( event.target.text, mapSearchLocationHandlerLocationHandler ) native.setKeyboardFocus( nil ) elseif event.phase == "editing" then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end function scene:create( event ) local sceneGroup = self.view --your code here; define display objects, sprites, physics bodies, etc - but don't play any sounds or animations yet. navBar = widget.newNavigationBar({ title = "Set Appointment Location", backgroundColor = { 0,0,0}, titleColor = {1, 1, 1}, }) sceneGroup:insert(navBar) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- any code placed here will run when the scene is still "off-screen", but about to be displayed to the user. In many cases, this will be empty. elseif ( phase == "did" ) then -- any code placed here will run as soon as the scene is displayed on screen. This is where you would start any animations, start playing background audio, start timers, etc. addressBar = native.newTextField(display.contentCenterX, navBar.y + 90, display.contentCenterX \* 1.8, 30) addressBar:addEventListener("userInput", addressBarHandler) sceneGroup:insert(addressBar) myMap = native.newMapView(0, 0,display.contentWidth , display.contentHeight + 50) if myMap then myMap.mapType = "standard" myMap.x = display.contentCenterX myMap.y = addressBar.y + 20 maplocationHandler() else native.showAlert( "Simulator", "Maps are only avaiable on device.", { "Okay" } ) end end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- any code placed here will run when the scene is still on screen, but is about to go off screen. This is where you would stop timers, audio, and animations that you created in the show event. elseif ( phase == "did" ) then -- any code placed here will run as soon as the scene is no longer visible. In many cases, this will be empty. addressBar:removeSelf() addressBar = nil if myMap and myMap.removeSelf then myMap:removeSelf() myMap = nil end end end function scene:destroy( event ) local sceneGroup = self.view -- any code placed here will run as the scene is being removed. Remove display objects, set variables to nil, etc. end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

Are you getting the gray screen in the sim or on device?

If on device, what’s going on in your console log?

Rob

on the device! how do i get to the console log on an android device?

It’s covered here:
http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

I’m gonna have to find a new device for this. This one is my friend’s phone and it is really old and the touch screen decides to randomly stop working, so i’ll get back to you really soon once I get the debugging stuff set up and ill let you know what it says.

Thanks!