NearbyRestaurantsMap web app enables users to search the restaurants:fork_and_knife:, cafes:coffee:, bars:beers: etc. around a circular area on a map. Found restaurants can be filtered using different criteria's like rating, cost. GOOGLE MAP API is used for the map and ZOMATO API for the restaurants data.
https://vbhosle.github.io/NearbyRestaurantsMap/
Note: Zomato uses OpenStreetMap, plotted markers location could be slightly different when viewed on Google Map.
Getting restaurants, bars, cafes in the area in three simple steps:
Note: Open index.html in javascript enabled browser.
-
Click the bouncing down arrow on the top right corner, to open options box.
-
Click Drawing Tools and draw a circle on the map.
-
Click Search Restaurants
In a happy scenario, you should get a list of restaurants within the circle and new filter button on the left. Click it to explore filter options.
Given location is loaded and the map is centered on it.
Zoom navigation is restricted to the places specified by the componentRestrictions
in the code.
It is currently set to the city: Mumbai, India
Enables you to draw, resize and reposition a circle on the map.
Only one circle is allowed at a time.
Enables you to draw, resize and reposition a circle on the map.
Zomato's free API key fetches maximum 20 locations. The locations are sorted by ascending order of the distance from the center of the circle. In the case of a circle covering a very large area, the locations may be dense near the center.
Once locations are plotted, FILTER sidebar button is visible on the left. Click it and sidebar will slide in.
Sidebar displays:
- an expandable Filter menu
- list of all filtered places.
The visible list of places on the sidebar and markers on the map satisfies all the selected filter conditions.
- Filter by Cuisine Type , ex. all, bakery:cake:, cafe:coffee:, pizza:pizza:
- Filter by Max cost for two π΅, between the minimum and maximum costs of the obtained places.
- Filter by Minimum Rating β, between 0-5
Clicking on the listed restaurant name or the marker plotted on the map, the restaurant is highlighted and details about the corresponding restaurant pop up.
After a successful search, top right option box offers only a New Search option.
On clicking New Search , previous search results are cleared.
- Web technologies: HTML, CSS, Javascript
- Javascript libraries/frameworks: JQuery, KnockoutJS
- APIs: GOOGLE MAP Javascript API, ZOMATO API
(as of 2017)
With Google Maps API, you can create interactive applications using Google maps .
It provides various libraries:
- drawing provides a graphical interface for users to draw polygons, rectangles, polylines, circles, and markers on the map.
- geometry includes utility functions for calculating scalar geometric values (such as distance and area) on the surface of the earth.
- places enable your application to search for places such as establishments, geographic locations, or prominent points of interest, within a defined area.
- visualization provides heatmaps for visual representation of data.
For detailed documentation visit Google Maps API.
Zomato APIs provides most exhaustive information for over 1.5 million restaurants across 23 countries and 10,000 cities globally. With the Zomato APIs, you can:
- Search for restaurants by name, cuisine, or location
- Display detailed information including ratings, location and cuisine
- Use the Zomato Foodie Index to show great areas to dine in a city
For usage details, visit Zomato API
-
Sign in with your Google - i.e. [email protected]. If you don't have one, you can go to accounts.google.com to create one for free.
-
Visit https://developers.google.com/maps/documentation/javascript/libraries and click GET KEY
-
Enable Google Maps Javascript API window pops up.
Specify a descriptive project name. Read and accept the terms and conditions. -
All Set!
Copy the generated API KEY. This action automatically enables Google Maps Javascript API and Geocoding API.
- Go to https://console.developers.google.com, it will land on the dashboard.
- Select the project you created. Then Credentials.
- Now you can restrict the API KEY usage to your application server only.
- Go to https://developers.zomato.com/api
- Sign in using existing Google/Facebook account or create a new account. If you are using existing accounts, allow ZOMATO access to your age and language.
- Enter your details to get the API KEY.
- You can experiment with the API right away on documentation page
-
In π index.html , look for
key=GOOGLE_MAP_API_KEY
, in the <script> tag nearly at the end of the HTML file. Replace theGOOGLE_MAP_API_KEY
with your Google Map Key. Don't add any spaces around. -
In π js/thirdPartyAPI.js , look for
ZOMATO_API_KEY = 'PASTE_ZOMATO_KEY';
ReplacePASTE_ZOMATO_KEY
with your ZOMATO KEY. Again no spaces around.
Current setup is for Mumbai, India
π‘ Tip: Use Google's geocode tool to get the lat/longs, country code, and administrativeArea.
- In π js/app.js ,
initMap
function, put the latitude and longitude of the city in{lat: , lng: }
map = new google.maps.Map(document.getElementById('map'), {
styles: styles,
center: {lat: 19.190638, lng: 72.834392},//Mumbai IN
.
.
}
- In π js/app.js , look for the following code:
geocoder.geocode(
{ address: address,
componentRestrictions: {country:'IN', administrativeArea: 'Mumbai'}
.
.
}
Change componentRestrictions
as per the city specified in first step with country code and city name.
- Zoom in location code inspired by Udacity's repo https://github.com/udacity/ud864
- Bouncing arrow inspired by https://codepen.io/dodozhang21/pen/siKtp
- Custom scrollbar inspired by https://codepen.io/devstreak/pen/dMYgeO
- Add place-autocomplete for zoom text box, reference
- Add restaurant thumbnail in the details.
- Navigation with keyboard shortcuts
- Add more filter options based on
- Has online delivery
- Has table booking
- input text-based filter with autocomplete.
- Gracefully spring apart overlapping location markers on click, with OverlappingMarkerSpiderfier library