O'Reilly logo

PHP and MongoDB Web Development by Rubayeet Islam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - finding restaurants near your location

In this example, we will build a web page that shows restaurants near the user's location. Similar to the earlier example, we will get the current location with the W3C Geolocation API, and mark it on a map rendered by the Google Maps API. Once the page is loaded and the location is marked on the map, we will perform an AJAX request to query MongoDB with the coordinates and get the location of the nearby restaurants (we will insert some sample data into the collection before hand):

  1. Launch the mongo shell and switch to the geolocation database:
    $./mongodb/bin/mongo MongoDB shell version: 1.8.1 connecting to: test > use geolocation switched to db geolocation
    
    
  2. Manually insert some sample data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required