A good starting point for all the behind the scenes code wrangling: google maps, sql, user location, distance formulas, etc. is in this iPhone book; can use that code as a blueprint across all languages:
Book: iPhone Cool Projects Finally, Steven Peterson demonstrates a comprehensive integration of iPhone technologies. He weaves Core Location, networking, XML, XPath, and SQLite into a solid and very useful application. http://apress.com/book/view/143022357x Our YogaLocal app is a free DL where you can see all this in action. Also if sticking 100% with php, this is a GREAT resource: This tutorial is intended for developers who are familiar with PHP/MySQL, and want to learn how to use Google Maps with a MySQL database to create a store locator-type app. After completing this tutorial, you will have a database of locations and a webpage that lets a user enter their address and see markers on a map for the locations nearest to them, within a chosen distance restriction. http://code.google.com/apis/maps/articles/phpsqlsearch.html On Fri, Jul 16, 2010 at 9:20 PM, Greg Rundlett (freephile) <g...@freephile.com> wrote: > OK, I'll bite... is the code somewhere so I can see how easy that is? > Didn't find it on iTunes nor the (http://www.yogalocal.com/) website. > Greg Rundlett > > > > > On Fri, Jul 16, 2010 at 8:29 PM, Edward Potter <edwardpot...@gmail.com> > wrote: >> >> >>> Given an array of businesses with latitude/longitude coordinates, and >> >>> the user's location, sort the array of businesses by closest to the user. >> >> A slight language digression: >> >> Oh my, if you saw how easy that was to do on an iPhone in ObjC >> (hundreds of locations). And then visualize it all on a google map >> with a detail view of everyone of those locations. With data updated >> in real-time. With a 5,000 mile server round trip. And do it all in a >> blink of the eye. >> (plus you get to talk to 4 orbiting satellites at the same time). Yummy! >> :-) >> >> Code in action here: (dropping, sorted pins by user location 1/2 way >> through). >> http://www.youtube.com/watch?v=krF9IUyF3Rw >> >> >> On Fri, Jul 16, 2010 at 4:36 PM, John Campbell <jcampbe...@gmail.com> >> wrote: >> > On Fri, Jul 16, 2010 at 2:48 PM, Hans Zaunere <li...@zaunere.com> wrote: >> >> Closures - great for Javascript, but for PHP? In a >> >> non-callback-centric >> >> synchronous language such as PHP, what else can we use this "syntactic >> >> sugar" for? How are people using them and what can we gain from them? >> >> And, >> >> the hell with code reuse? >> > >> > I have a favorite problem, that is hard/ugly to solve without closures: >> > >> > Given an array of businesses with latitude/longitude coordinates, and >> > the user's location, sort the array of businesses by closest to the >> > user. >> > >> > so you have: >> > >> > $stores = array( >> > array('name' => 'Pet Smart', 'lat'=>24.12, 'lon' => 54.23), >> > array('name' => 'Cats and Critter', 'lat'=>24.19, 'lon' => 54.32), >> > array('name' => 'Snakes and such', 'lat'=>24.45, 'lon' => 53.35), >> > array('name' => 'Lots of llams', 'lat'=>24.46, 'lon' => 54.97)); >> > >> > $user_location = array('lat'=> 24.45, 'lon' => 54.96); >> > >> > // Solution using closures >> > >> > // geo sort. >> > function sort_by_closest(&$points,$location) { >> > usort($points, function($a,$b) use($location) { >> > return distance($a,$location) > distance($b,$location); >> > }); >> > } >> > >> > // geo distance using sperical law of cosines. >> > function distance($a,$b) { >> > $R = 6371; // km >> > $d2r = pi() / 180; >> > return acos(sin($a['lat']*$d2r)*sin($b['lat']*$d2r) + >> > cos($a['lat']*$d2r)*cos($b['lat']*$d2r) * >> > cos($b['lon']*$d2r-$a['lon']*$d2r)) * $R; >> > } >> > >> > print_r($stores); >> > sort_by_closest($stores,$user_location); >> > print_r($stores); >> > >> > >> > -John >> > _______________________________________________ >> > New York PHP Users Group Community Talk Mailing List >> > http://lists.nyphp.org/mailman/listinfo/talk >> > >> > http://www.nyphp.org/Show-Participation >> > >> >> >> >> -- >> IM/iChat: ejpusa >> Links: http://del.icio.us/ejpusa >> Follow me: http://www.twitter.com/ejpusa >> Karma: http://www.coderswithconscience.com >> _______________________________________________ >> New York PHP Users Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/Show-Participation > > > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation > -- IM/iChat: ejpusa Links: http://del.icio.us/ejpusa Follow me: http://www.twitter.com/ejpusa Karma: http://www.coderswithconscience.com _______________________________________________ New York PHP Users Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/Show-Participation