官术网_书友最值得收藏!

Step-by-step bootstrap

The next section covers detailed instructions to set up your development environment to rapidly create visualizations in later chapters. By the end of the chapter, you will have a working environment for the rest of the book (an example of a map running and an initial look at tools used to create visualizations).

A lightweight web server

Technically, most of the content we will craft can render directly in the browser without the use of a web server. However, we highly recommend you not to go ahead with this approach. Running a web server in your local development environment is extremely easy and provides several benefits:

  • Geographic information, statistical data, and visualization code can be clearly separated into isolated files
  • API calls can be stubbed and simulated, allowing easy integration into a full-stack application in the future
  • It will prevent common mistakes when making AJAX calls to fetch geographic and statistical data (for example, the same-origin policy)

For our choice of the web server and other tools in our toolbox, we will rely on a Node.js package named http-server. Node.js is a platform built on Chrome's JavaScript runtime, which is used to build fast, scalable network applications. The platform includes Node Package Manager (npm), which was created by other members of the vibrant Node.js community and allows the developer to quickly install packages of prebuilt software.

To install Node.js, simply perform the following steps:

  1. Go to the website http://nodejs.org.
  2. Click on the INSTALL button.
  3. Open the downloaded package and follow the defaults.

To test the installation, type in the following in the command line:

node –v
v0.10.26 # or something similar should return

Now that Node.js and npm are installed, we can proceed to install the web server. When the web server is installed globally with the –g command, it becomes easily accessible throughout the system.

Once on the command line, enter the following:

npm install -g http-server

You can quickly verify the package was installed by typing the following:

http-server

Then open your web browser to http://localhost:8080. The browser should display a list of all the files in the directory from where you initiated the command.

主站蜘蛛池模板: 原阳县| 青岛市| 平罗县| 定西市| 牡丹江市| 井研县| 于田县| 安义县| 平度市| 海宁市| 抚州市| 绥棱县| 南平市| 汶上县| 浦北县| 西昌市| 乳山市| 海门市| 探索| 敦化市| 怀柔区| 河东区| 益阳市| 鄂伦春自治旗| 宜州市| 黄石市| 嘉禾县| 准格尔旗| 曲麻莱县| 西乡县| 永定县| 岚皋县| 新沂市| 隆子县| 砀山县| 清水县| 宁德市| 佛坪县| 丰台区| 肥东县| 韶关市|