项目作者: gauravsinghaec

项目描述 :
Neighborhood Map Project using React and Google Map APIs
高级语言: JavaScript
项目地址: git://github.com/gauravsinghaec/FEND-Neighborhood-Map-React.git


Neighborhood Map React Project

This project is developed using Google Map API and React. The initial location data (to load onto the map)
is being fetched from Foursquare third party API. You can filter the location from
the text filter section and the map markers & place listings will be updated on real-time based on the
input text. Also you will be able to get the details about each place by selecting the place from the
listing or by clicking on the individual map markers.

Table of Contents

Getting Started

You need to set up the application before you can see it running live in your browser.
Please check the installation section to know more.

Project URL

image

Create React App

This project was bootstrapped with Create React App. You can find more information on how to perform common tasks here.

Folder Structure

Your project folder should look like this:

  1. ├── README.md - This file.
  2. ├── package.json # npm package manager file. It's unlikely that you'll need to modify this.
  3. ├── .eslintrc.json # eslint configuration settings
  4. ├── public
  5. ├── favicon.ico # React Icon,
  6. └── index.html # DO NOT MODIFY
  7. ├── build It contains the production ready code
  8. └── src
  9. ├── App.css # Styles for your app.
  10. ├── App.js # This is the root of the app.
  11. ├── GoogleMap.js # React Map component
  12. ├── PlaceList.js # React place list component
  13. ├── Toggle.js # A React component for hamburger menu
  14. ├── registerServiceWorker.js # registers service worker in production environment
  15. ├── index.css # Global styles.
  16. └── index.js # It is used for DOM rendering only.

Prerequisites

  • ES6, Promises, REACT, Service Worker, A11y

How to launch the app locally?

Installation

  1. Clone the Project - https://github.com/gauravsinghaec/FEND-Neighborhood-Map-React.git
  2. Go into the directory where the project now lives - cd FEND-Neighborhood-Map-React
  3. Install the dependencies - npm install
  4. Start the app - npm start
    1. The application will be running at http://localhost:8000 URL

Deploy to gh-pages

  1. Add the following scripts in your package.json and also add the “homepage”:

    “homepage”: “https://.github.io/“,

    “scripts”: {

    • “predeploy”: “npm run build”,
    • “deploy”: “gh-pages -d build”,
      }
  2. Install the gh-pages module to create gh-pages branch on github during deployment.

    1. >>>npm install --save gh-pages
  3. Deploy the app - Below command is used to deploy the React app to the gh-pages but before that we need few pre-requisite.

    1. >>>npm run deploy

    image

  4. Now there will be a new branch in your GitHub repo “gh-pages” where the build files will be present and
    do check the gh-pages section in GitHub repo setting to see the hosted URL.

image

Offline Use and Service Worker

By default, the create-react-app includes a service worker in the production build.
Do check the below steps to see service worker in action after production build

  1. Build the app to generate production version and test.

    1. npm run build

    image

  2. Now the build folder will look like below:
    image

  3. Static Server - Set up your favorite HTTP server so that a visitor to your site is served index.html.
    For environments using Node, the easiest way to handle this would be to install serve and let it handle the rest:

    1. >>>npm install g serve
    2. >>>serve s build

    image

  4. Service Worker running in the browser.
    image

  5. Service Worker caching main.{hash}.js, main.{hash}.js and index.html for offline access.
    image

Thirt Party APIs

Here I am using Kolkata Coordinate 22.5726° N, 88.3639° E to get the neighboring locations

  1. * Wiki API
  2. We are fetching the wiki data from this API about each place and hence showing in the infowindow
  3. when marker is clicked on the map.

Wiki fetch API url
https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&search=Belgium&limit=5
```

Resources

Authors

  • Gaurav Singh

Acknowledgments

  • Special thanks to Udacity Team