How to mirror an iPhone map in a web page - iphone

Basically I want to send gps coordinates (displayed on a map in the iPhone) from the iPhone to a webserver that store the values in a database. You should then be able to retrieve these coordinates and display them on a web page.
I am thinking of a set up like this:
I want the browser to request and receive the coordinates in real time (every 10 seconds or so) and I'm wondering if this is a good way to mirror the map in a browser or should I use a different approach? Finally, can you see any obvious flaw/flaws in this design (i.e. performance issues)?

your setup makes sense. The question is, what will you use to keep the map in the browser up to date? I would suggest you check out http://socket.io, I think it will do exactly what you need.
Cheers,
Johannes

Related

Getting current location and posting it to a web service

Ok... maybe forbidden by Apple, but assuming this is permitted. What would be the best way to get the current location (not difficult) and posting it to a web service (also not much of a challenge). The app is for an artist who wants people to see where he is at the moment. Personally, I wouldn't want people to know where I am 24/7 but that's performance art I guess. An exact location is not wanted but a town or area would be preferred. I could modify the string when it gets to the server and make it more vague by rounding the LOG and LAT.
The app the fans would use would retrieve his current location from the server and update the map view with a location.
I suppose one way would be for him to find out his coordinates and post that to a web page but I'd like it to update automatically.
A response with code is not necessary, just a general opinion on methodology/advisability would be appreciated
I would probably give him a webpage to go to that records his position every time he visits. It would be a private URL, and perhaps use some lightweight authentication. For versatility, I'd record the exact position in the database (in case he changes his mind on how it should work later on). However, you could use an external service or another purchased database with zips or city information with lat/lng data, so you could just provide users of the client app with his general vicinity rather than exact location.
The alternative would be to give him an ad hoc app that does the same thing, but putting together that location recording webpage would be a much simpler process. Could be handy for other things, too.
Here's a little writeup about getting location from mobile Safari, just as a reference: http://mobiforge.com/developing/story/location-iphone-web-apps
Why wouldn't you just use google latitude and read out his status?
I think this should really be done as a web page web-app. You can get coordinates from the device through mobile safari and you can skip the app approval process. You can also set it up so it runs fullscreen on his phone and he won't know the difference. You can also put a password on it.
There is a good chance it would not get approved as a regular app.
You can always meta refresh the page to keep it updating.
http://smithsrus.com/gps-geolocation-in-safari-on-iphone-os-3-0/
"Artist" must log in to his application (thus insuring that he want to share his coordinates with your webserver), then you use CLLocationManager to get his coordinates and make a reverse geocoding using Google Maps API to get country and city for given coordinates.
Can't see anything special about it :)

I'm trying to understand the concept of pulling information off the web and into an app Please!

Generally speaking, how does an app like "Around Me" acquire the information it displays?
For example: the restaurants that show up in a list that are near me with the address and distance (I think I get the distance piece) where is this information extracted from? Is it Google or something?
I'm not asking how to implement this (that's over my head!) just get an idea of how it occurs.
Thanks StackOverFlow people.
I haven't seen that specific app, but most such apps either have an embedded database of locations or they dynamically query a server back-end (e.g. using HTTP) to fetch a set of locations near you. They know where you are because the app has access to location services to find out your geographic location.
The iPhone has a GPS unit which gives you your latitude and longitude, which it then sends to a backend server (Say Google Maps) and queries it for, in your case a restaurant. The server responds with a set of locations around you.

Should loaded images and text be stored in memory or retrieved each time

My app has various pins that drop onto a map and when you click on the pins you get more information about this entity.
Each time you click on the entity it retrieves the information from a web service. Should I only retrieve this information once and store it in memory or should I retrieve it each time that page loads?
It's a small about of text and 3 small images?
If its just 3 small images and some text that will not change i would probably cache them in the application instead of retriving them over and over, it will provide a better user expirience in my opinion...
Also I have a Core Data application that uses images...
I tried both methods but I chose to retrieve it every time because for my goal is the best practice. However this method causes me to write some code and a lot of if and else!
How Daniel said, cache each image can be a better solution for your problem because if an user would like to retrieve these images from internet but the connections isn't fast, he'll wait a lot of time...

get data from online once and then viewable offline

Okay, I want to have an app that takes phone numbers from an online database and displays them in a table view. When the user is not online, I want them to still be able to see the numbers they already got from the database in the table view. If the user manages to go back online, the database updates the view. My question is, is this possible to do and if so, what's the best way to approach it? (bit of a newbie, please help me out)
There are many ways to do what you are asking, depending on the complexity of what you are after.
Could I suggest the following steps (I'm not sure which ones you can do, and which ones you are having trouble with).
Connect to the server and retrieve the list of phone numbers
If the database has a web server front end this might be as simple as sending a get request to the server (see NSURLConnection) and parsing the result. Otherwise you will need to know/tell us what type database you are using.
Store the phone numbers on the device
Use SQLite to store the numbers on the device (See iPhone SQLite Resources)
Check for internet connectivity
Periodically check for internet connectivity, and if a specific time has elapsed since you last polled the server, retry. (See Checking iPhone internet connectivity)
Although you’re probably looking for a native app solution, you can also do this with a web app.
http://diveintohtml5.ep.io/offline.html
I am a new developer iPhone developer, "learning" to be precise. I came across the useful NSUserDefaults (a dictionary in which you can store/restore state even after your application relaunches). Problem with this dictionary will be memory in your case. NSUserDefaults is sort of global to all applications and yours may spoil the show for other innocent applications (like Weather :D ).
To work around this, you can have your application declare a property list file where you store a few numbers (best practise would be the most recent but you can use any selector of choice). Look for an appropriate time in your run loop to store these numbers into your property file and load them when the application starts.

best way to store data locally and update from web from time to time?

I have created an app which displays information in a organized manner about cultural places.
The information is subject to changes, so I want it to be downloaded from the web. But not everytime. Only once in a while, because information doesn't change often.
What I want to do is, the first time the user opens the application, it downloads all data from the web. For the moment, I parse it from an xml (which is about 100Ko), and I get a NSMutableArray of "CulturalPlace" objects. but it is very slow. And what I would like to do is, to store this data locally (in case the user has an iPod touch an is not on a wifi, or if he is on EDGE and does not want to redownload all). So the user updates data only by clicking an "update button" on the top right of the screen. Otherwise it reads it from disk.
I really don't know what could be the best solution. I thought about Core Data, but I have several Tableview imbricated (Rootviewcontroller > ListofPlacesViewController > PlaceViewController) and I really cannot find good tutorial for a simple use like mine. (the iTunes "TopSongs" sample code seems too complex).
I thought also about not parsing the xml, but instead try an NSURLConnection and get a plist file. But I never managed to read anything from the local file.
So my main question is, should I keep the xml parsing method, or should I use another format to tranfert the data from the web? And what is the best way to store and read data like an NSMutableArray of custom Objects ?
Thanks in advance for your help, sorry for my approximate english.
You could use HTML5' localStorage. It's supported by Chrome and FF on the PC and Safari on Mac OS and iPhone (to the best of my knowledge). It acts like a local database. Bear in mind that if the user selects to clear all cookies (or "private settings"), your storage goes away.
You could opt to store the XML locally, and store in NSUserDefaults the date when last updated - then on app launch you can check to see if you have a new file.
ASIHTTPRequest makes it pretty easy to say "Save the contents of this URL to a file". So you'd always save the XML to a file, and always read from that file or fetch XML if it was not yet there.
In my experience XML is indeed much slower to parse than plist, even though they're technically the same thing. Fortunately, plist's are pretty easy to deal with and the API's take care of all of the archiving and de-archiving.
Once you have your data in memory, it probably wouldn't be too hard to convert it to the much faster plist representation, check out this doc for more info: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/Archiving/Archiving.html
If your app is divided into different pages, you might also consider splitting the file into separate files, and only parsing / de-archiving the information you need when you need it (if you did this on a separate thread and displayed a UIProgressView on the main thread, the delay would probably be barely an issue to the user).