Professional Documents
Culture Documents
Textbook Building Web and Mobile Arcgis Server Applications With Javascript Lewin Ebook All Chapter PDF
Textbook Building Web and Mobile Arcgis Server Applications With Javascript Lewin Ebook All Chapter PDF
https://textbookfull.com/product/programming-kotlin-applications-
building-mobile-and-server-side-applications-with-kotlin-1st-
edition-brett-mclaughlin/
https://textbookfull.com/product/learning-react-native-building-
native-mobile-apps-with-javascript-2nd-edition-bonnie-eisenman/
https://textbookfull.com/product/client-server-web-apps-with-
javascript-and-java-rich-scalable-and-restful-1st-edition-
saternos-casimir/
Server Side Swift with Vapor Building Web APIs and Web
Apps in Swift 3rd Edition Raywenderlich.Com Tutorial
Team
https://textbookfull.com/product/server-side-swift-with-vapor-
building-web-apis-and-web-apps-in-swift-3rd-edition-
raywenderlich-com-tutorial-team/
The Definitive Guide to AdonisJs: Building Node.js
Applications with JavaScript Christopher Pitt
https://textbookfull.com/product/the-definitive-guide-to-
adonisjs-building-node-js-applications-with-javascript-
christopher-pitt/
https://textbookfull.com/product/building-react-apps-with-server-
side-rendering-use-react-redux-and-next-to-build-full-server-
side-rendering-applications-thakkar-mohit/
https://textbookfull.com/product/building-react-apps-with-server-
side-rendering-use-react-redux-and-next-to-build-full-server-
side-rendering-applications-thakkar-mohit-2/
https://textbookfull.com/product/practical-rust-web-projects-
building-cloud-and-web-based-applications-shing-lyu/
https://textbookfull.com/product/web-api-cookbook-level-up-your-
javascript-applications-joe-attardi/
Building Web and Mobile ArcGIS Server Applications with JavaScript
Second Edition
Build exciting custom web and mobile GIS applications with the ArcGIS Server API
for JavaScript
Eric Pimpler
Mark Lewin
BIRMINGHAM - MUMBAI
Building Web and Mobile ArcGIS
Server Applications with JavaScript
Second Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
www.packtpub.com
Credits
Authors
Copy Editor
Eric Pimpler
Safis Editing
Mark Lewin
Reviewers
Project Coordinator
Ken Doman
Vaidehi Sawant
Adeyemo Ayodele
Mark Lewin has been developing, teaching, and writing about software for over 16
years. His main interest is GIS and web mapping. Working for ESRI, the world's
largest GIS company, he has been a consultant, trainer and course author, and a
frequent speaker at industry events. He has subsequently expanded his knowledge to
include a wide variety of open source mapping technologies and a handful of
relevant JavaScript frameworks, including Node.js, Dojo, and JQuery. Mark now
works within Oracle's MySQL curriculum team, focusing on creating great learning
experiences for DBAs and database developers, but remains crazy about web
mapping.
About the Reviewers
Ken Doman is a senior frontend engineer at GEO Jobe, a geographic information
systems consultant company and ESRI business partner that helps public sector
organizations and private sector businesses get the most out of geospatial solutions.
Ken has worked for the municipal government and in the private sector. He has
experienced many facets of GIS technology, from field data collection to mapping
and data analysis to creating and deploying web mapping applications and solutions.
Ken is the author of Mastering ArcGIS Server Development with JavaScript. He has
also reviewed several books for Packt Publishing, including Building Web and
Mobile ArcGIS Server Applications with JavaScript and Spatial Analysis with
ArcGIS by Eric Pimpler, ArcGIS for Desktop Cookbook by Daniela Christiana
Docan, and ArcPy and ArcGIS by Silas Toms.
"I’d first like to thank my wife, Luann, who puts up with my late nights reviewing
books like this. I’d like to thank my current employer," GEO Jobe "GIS Consulting,
as well as past employers like Bruce Harris and Associates, City of Plantation," FL
"and City of Jacksonville, TX for believing in me and letting me learn so much on the
job. Finally, I’d like to thank my creator for putting me where I need to be.
"
Ayodele Adeyemo is a geogeek with over four years experience, and is passionate
about leveraging data and technology to provide solutions to human, social, and
technological problems. He currently works with eHealth Africa in Nigeria with the
Global Health and Informatics department to provide user data and technology to
solve health issues across communities in Africa. He has experience in building and
mentoring geospatial solutions as well as consulting for organizations on how to
deploy sustainable geospatial solutions to support their agencies and projects.
Ayodele has worked as GIS Specialist at eHealth Africa and Founder and Latitudes
Tech Limited. He has worked on the book ArcPy and ArcGIS: Automating ArcGIS
for Desktop and ArcGIS Online with Python.
"I'd like to thank my manager, Dami Sonoiki; my supervisor, Samuel Aiyeoribe; and
my colleagues Samuel Okoroafor and Seun Egbinola."
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get
in touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all
Packt books and video courses, as well as industry-leading tools to help you plan
your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our
editorial process. To help us improve, please leave us an honest review on this
book's Amazon page at https://www.amazon.com/dp/1787280527.
If you'd like to join our team of regular reviewers, you can e-mail us at
customerreviews@packtpub.com. We award our regular reviewers with free eBooks and
videos in exchange for their valuable feedback. Help us be relentless in improving
our products!
Table of Contents
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to HTML, CSS, and JavaScript
Basic HTML page concepts
DOCTYPE
Primary tags
Validating HTML code
JavaScript fundamentals
Commenting code
Variables
JavaScript is case sensitive
Variable data types
Decision support statements
Looping statements
Functions
Objects
Basic CSS principles
CSS syntax
Inline styling
Internal style sheet
External style sheet
Separating HTML, CSS, and JavaScript
Summary
2. Creating Maps and Adding Layers
The ArcGIS API for JavaScript Sandbox
Basic steps for creating an application with the ArcGIS API for JavaScript
Creating HTML code for the page
Referencing the ArcGIS API for JavaScript
Loading API modules
Making sure the DOM is available
Creating the map
Creating the page content
Styling the page
The entire code
More about the map
Working with map service layers
Using the layer classes
Tiled map service layers
Dynamic map service layers
Adding layers to the map
Setting the visible layers from a map service
Setting a definition expression
Map navigation
Map navigation widgets and toolbars
Map Navigation with the mouse and keyboard
Getting and setting the map extent
Map events
Summary
3. Adding Graphics to the Map
The four parts of a Graphic
Specifying graphic geometry
Symbolizing graphics
Assigning attributes to graphics
Changing graphic attributes in an InfoTemplate
Creating the graphic
Adding graphics to the GraphicsLayer
Multiple GraphicsLayers
Practice time
Summary
4. The Feature Layer
Creating the FeatureLayer
Optional constructor parameters
Defining the display mode
The snapshot mode
The on-demand mode
The selection only mode
The auto mode
Setting a definition expression
Feature selection
Rendering FeatureLayer
Practice time
Summary
5. Using Widgets and Toolbars
Adding toolbars to an application
Steps for creating a toolbar
Defining CSS styles
Creating the buttons
Creating an instance of the Navigation toolbar
User interface widgets
The BasemapGallery widget
Basemap toggle widget
Bookmarks widget
The Print widget
Layer List widget
Time to practice
Search widget
Gauge widget
Measurement widget
The Popup widget
Legend widget
OverviewMap widget
Scalebar widget
Directions
HistogramTimeSlider
HomeButton
LocateButton
TimeSlider
LayerSwipe
The Analysis widgets
Feature editing
FeatureService
The Editing widgets
The Editor widget
TemplatePicker widget
AttributeInspector widget
The AttachmentEditor widget
The Edit toolbar
Summary
6. Performing Spatial and Attribute Queries
Introducing tasks in ArcGIS Server
Overview of attribute and spatial queries
The Query object
Setting query properties
Attribute queries
Spatial queries
Limiting the fields returned
Executing the query with QueryTask
Getting the results of the query
Practice time with spatial queries
Summary
7. Identifying and Finding Features
Using IdentifyTask to access feature attributes
Introducing IdentifyTask
IdentifyParameters
IdentifyTask
IdentifyResult
Practice time - implementing identify functionality
Using FindTask to access feature attributes
FindParameters
FindTask
FindResults
Summary
8. Turning Addresses into Points and Points into Addresses
Introduction to geocoding
Geocoding with a locator service in the ArcGIS API for JavaScript
Input parameter object
Input JSON address object
Input point object
Locator object
The AddressCandidate object
The geocoding process
The reverse geocoding process
Practice time with the locator service
The Search widget
Summary
9. Directions and Routing
Routing task
Practice time with routing
The Directions widget
ClosestFacility Task
ServiceArea task
Summary
10. Geoprocessing Tasks
Models in ArcGIS Server
Using the Geoprocessor task - what you need to know
Understanding the services page for a geoprocessing task
Input parameters
The Geoprocessor task
Executing the task
Synchronous tasks
Asynchronous tasks
Practice time with geoprocessing tasks
Summary
11. Geometry Operations
The Geometry Service
Geometry Service operations
Using the Geometry Service
The Geometry Engine
Practice time with the Geometry Engine
Summary
12. Integration with ArcGIS Online
Adding ArcGIS Online maps to your applications by using a webmap ID
Adding ArcGIS Online maps to your applications with JSON
Practice time with ArcGIS Online
Summary
13. Creating Mobile Applications
Compact build of the API
Setting the viewport scale
Practice time with the compact build
Integrating the geolocation API
Practice time with the geolocation API
Summary
14. Looking Ahead - Version 4 of the ArcGIS API for JavaScript
Steps for creating 2D maps
Accessing layers
New and changed layers
GraphicsLayer
FeatureLayer
MapImageLayer
VectorTileLayer
GroupLayers
SceneLayers
3D mapping and symbology
Scenes
Creating the map
Setting elevation data
Setting the camera
Specifying the environment
Local scenes
3D symbology and rendering
Summary
Preface
ArcGIS Server is the predominant platform for developing GIS applications for the
web. In the past, you could choose from a number of programming languages to
develop web mapping applications with ArcGIS Server, including JavaScript, Flex,
and Silverlight. However, the Flex and Silverlight APIs have now retired, leaving
JavaScript as the preferred language for developing applications on this platform. Its
advantages over other languages include the fact that you can use it to build both
web and mobile applications and that it does not require the installation of a plugin:
everything runs natively in the browser.
This book will teach you how to build web-based GIS applications using the ArcGIS
API for JavaScript. Using a practical hands-on style of learning, you will learn how
to build fully functional applications with ArcGIS Server and, in doing so, develop a
skillset that is in high demand.
You will learn how to create maps and add geographic layers from a variety of
sources, including tiled and dynamic map services. In addition, you'll learn how to
add vector graphics to the map and stream geographic features to the browser using a
feature layer. Most applications also include specific functionality implemented by
ArcGIS Server as tasks. You'll learn how to use the various tasks provided by
ArcGIS Server to perform common GIS operations, including queries, identification
of features, finding features by attribute, geoprocessing tasks, and more. Finally,
you'll learn just how easy it is to develop mobile applications with the ArcGIS API
for JavaScript.
What this book covers
Chapter 1, Introduction to HTML, CSS, and JavaScript, covers the fundamental
HTML, CSS, and JavaScript concepts before getting started with developing GIS
applications with the ArcGIS API for JavaScript.
Chapter 2, Creating Maps and Adding Layers, shows how to create a map and add
layers to the map. You will learn how to create an instance of the Map class, add
layers of data to the map, and display this information on a web page. Map is the
most fundamental class in the API as it provides the canvas for your data layers and
any subsequent activities that occur in your application. However, your map is
useless until you add layers of data. There are several types of data layers that can be
added to a map, including tiled, dynamic, feature, and others. You will learn more
about each of these layer types in this chapter as well.
Chapter 4, The Feature Layer, describes FeatureLayer. This inherits from the
GraphicsLayer, but offers additional capabilities such as the ability to perform queries
and selections. Feature layers are also used for online editing of features. Feature
layers differ from tiled and dynamic map service layers because feature layers bring
geometry information to the client computer to be drawn and stored by the web
browser. Feature layers potentially cut down on round trips to the server. A client
can request the features it needs and perform selections and queries on those features
without having to request more information from the server.
Chapter 5, Using Widgets and Toolbars, covers out-of-the-box widgets that you can
drop into your application for enhanced productivity. These include the basemap
gallery. Bookmark, print, and overview map user interface components. In addition,
the ArcGIS API for JavaScript also includes helper classes for creating toolbars
within your applications, such as navigation and drawing toolbars.
Chapter 6, Performing Spatial and Attribute Queries, covers the ArcGIS Server Query
Task that allows you to perform attribute and spatial queries against data layers in a
map service that have been exposed. You can also combine these query types to
perform a combination attribute and spatial query.
Chapter 7, Identifying and Finding Features, covers two common operations found in
any GIS application: clicking a feature on the map to identify it, or performing a
query to locate features with specific attribute values. In either case, information
about particular features is returned. In this chapter the reader will learn how to use
the IdentifyTask and FindTask objects to obtain information about features.
Chapter 8, Turning Addresses into Points and Points into Addresses, covers the use of
the Locator task to perform geocoding and reverse geocoding. Geocoding is the
process of assigning a coordinate to an address while reverse geocoding assigns an
address to a coordinate.
Chapter 9, Directions and Routing, describes how to access ArcGIS Server network
analysis services to perform analyses on street networks, such as finding the best
route from one address to another, finding the closest school, identifying a service
area around a location, or responding to a set of orders with a fleet of service
vehicles.
Chapter 11, Geometry Operations, describes how to use the ArcGIS Server Geometry
Service, and its client-side counterpart, the Geometry Engine, to execute common
geometric operations such as buffering a feature and reprojecting from one
coordinate system to another.
Chapter 12, Integration with ArcGIS Online, details how you can use the ArcGIS API
for JavaScript to access data and maps created with ArcGIS.com, which is a web site
for working with maps and other types of geographic information. On this site, you
will find applications for building and sharing maps. You will also find useful
basemaps, data, applications, and tools that you can view and use along with
communities you can join. For application developers the really exciting news is that
you can integrate ArcGIS.com content into your custom developed applications using
the ArcGIS API for JavaScript. This chapter shows you how.
Chapter 13, Creating Mobile Applications, describes how to build mobile GIS
applications using the ArcGIS API for JavaScript. ArcGIS Server support is
currently provided for iOS and Android devices. In this chapter, you'll learn about
the compact build of the API that makes web mapping applications possible through
the use of Dojo Mobile.
Appendix, Looking Ahead at Version 4 of the ArcGIS API for JavaScript, gives you a
broad overview of what to expect in version 4 of the API. This is a complete
reworking of the API that is being developed in parallel with version 3.x.
What you need for this book
To complete the activities in this book, you will need access to a web browser--
preferably Google Chrome or Firefox. Each chapter contains practices designed to
supplement the material presented. You will complete these practices using the
ArcGIS API for JavaScript Sandbox to write and test your code. The sandbox can be
found at https://developers.arcgis.com/javascript/3/sandbox/sandbox.html. All the practices
will access publicly available instances of ArcGIS Server, so you will not need to
install ArcGIS Server yourself.
Who this book is for
This book is written for application developers who want to develop web and mobile
GIS applications using ArcGIS Server and the API for JavaScript. It is primarily
oriented toward beginning and intermediate-level GIS developers or to more
traditional application developers who may not have developed GIS applications in
the past but who are now tasked with implementing solutions on this platform. No
prior experience with ArcGIS Server, JavaScript, HTML, or CSS is expected, but it
is certainly helpful.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"We can include other contexts through the use of the include directive."
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
function computeServiceArea(evt) {
map.graphics.clear();
var pointSymbol = new SimpleMarkerSymbol();
pointSymbol.setOutline = new
SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0,
0]), 1);
pointSymbol.setSize(14);
pointSymbol.setColor(new Color([0, 255, 0, 0.25]));
}
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "clicking
the Next button moves you to the next screen".
Robert Hart,
The Peking Legations
(Fortnightly Review, November, 1900).
{109}
For some weeks after this the Boxer movement appears to have
been under constraint. Further outrages were not reported and
no expressions of anxiety appear in the despatches from
Peking. The proposal of a joint naval demonstration in the
waters of Northern China was not pressed.
"May 17.
The French Minister called to-day to inform me that the Boxers
have destroyed three villages and killed 61 Roman Catholic
Christian converts at a place 90 miles from Peking, near
Paoting-fu. The French Bishop informs me that in that
district, and around Tien-tsin and Peking generally, much
disorder prevails."
"May 18.
There was a report yesterday, which has been confirmed to-day,
that the Boxers have destroyed the London Mission chapel at
Kung-tsun, and killed the Chinese preacher. Kung-tsun is about
40 miles south-west of Peking."
"May 19.
At the Yamên, yesterday, I reminded the Ministers how I had
unceasingly warned them during the last six months how
dangerous it was not to take adequate measures in suppression
of the Boxer Societies. I said that the result of the apathy
of the Chinese Government was that now a Mission chapel, a few
miles distant from the capital, had been destroyed. The
Ministers admitted that the danger of the Boxer movement had
not previously appeared to them so urgent, but that now they
fully saw how serious it was. On the previous day an Imperial
Decree had been issued, whereby specified metropolitan and
provincial authorities were directed to adopt stringent
measures to suppress the Boxers. This, they believed, would
not fail to have the desired effect."
"May 21.
All eleven foreign Representatives attended a meeting of the
Diplomatic Body held yesterday afternoon, at the instance of
the French Minister. The doyen was empowered to write, in the
name of all the foreign Representatives, a note to the Yamên
to the effect that the Diplomatic Body, basing their demands
on the Decrees already issued by the Palace denunciatory of
the Boxers, requested that all persons who should print,
publish, or disseminate placards which menaced foreigners, all
individuals aiding and abetting, all owners of houses or
temples now used as meeting places for Boxers, should be
arrested. They also demanded that those guilty of arson,
murder, outrages, &c., together with those affording support
or direction to Boxers while committing such outrages, should
be executed. Finally, the publication of a Decree in Peking
and the Northern Provinces setting forth the above. The
foreign Representatives decided at their meeting to take
further measures if the disturbances still continued, or if a
favorable answer was not received to their note within five
days. The meeting did not decide what measures should be
taken, but the Representatives were generally averse to
bringing guards to Peking, and, what found most favour, was as
follows:—
{110}
"May 24.
Her Majesty's Consul at Tien-tsin reported by telegraph
yesterday that a Colonel in charge of a party of the Viceroy's
cavalry was caught, on the 22nd instant, in an ambuscade near
Lai-shui, which is about 50 miles south-west of Peking. The
party were destroyed."
"May 25.
Tsung-li Yamên have replied to the note sent by the doyen of
the Corps Diplomatique, reported in my telegram of the 21st
May. They state that the main lines of the measures already in
force agree with those required by the foreign
Representatives, and add that a further Decree, which will
direct efficacious action, is being asked for. The above does
not even promise efficacious action, and, in my personal
opinion, is unsatisfactory."
"May 27.
At the meeting of the Corps Diplomatique, which took place
yesterday evening, we were informed by the French Minister
that all his information led him to believe that a serious
outbreak, which would endanger the lives of all European
residents in Peking, was on the point of breaking out. The
Italian Minister confirmed the information received by M.
Pichon. The Russian Minister agreed with his Italian and
French colleagues in considering the latest reply of the Yamên
to be unsatisfactory, adding that, in his opinion, the Chinese
Government was now about to adopt effective measures. That the
danger was imminent he doubted, but said that it was not
possible to disregard the evidence adduced by the French
Minister. We all agreed with this last remark. M. Pichon then
urged that if the Chinese Government did not at once take
action guards should at once be brought up by the foreign
Representatives. Some discussion then ensued, after which it
was determined that a precise statement should be demanded
from the Yamên as to the measures they had taken, also that
the terms of the Edict mentioned by them should be
communicated to the foreign Representatives. Failing a reply
from the Yamên of a satisfactory nature by this afternoon, it
was resolved that guards should be sent for. Baron von
Ketteler, the German Minister, declared that he considered the
Chinese Government was crumbling to pieces, and that he did
not believe that any action based on the assumption of their
stability could be efficacious. The French Minister is, I am
certain, genuinely convinced that the danger is real, and
owing to his means of information he is well qualified to
judge. … I had an interview with Prince Ch'ing and the Yamên
Ministers this afternoon. Energetic measures are now being
taken against the Boxers by the Government, whom the progress
of the Boxer movement has, at last, thoroughly alarmed. The
Corps Diplomatique, who met in the course of the day, have
decided to wait another twenty-four hours for further
developments."
"May 29.
Some stations on the line, among others Yengtai, 6 miles from
Peking, together with machine sheds and European houses, were
burnt yesterday by the Boxers. The line has also been torn up
in places. Trains between this and Tien-tsin have stopped
running, and traffic has not been resumed yet. The situation
here is serious, and so far the Imperial troops have done
nothing. It was unanimously decided, at a meeting of foreign
Representatives yesterday, to send for guards for the
Legations, in view of the apathy of the Chinese Government and
the gravity of the situation. Before the meeting assembled,
the French Minister had already sent for his."
"May 30.
Permission for the guards to come to Peking has been refused
by the Yamên. I think, however, that they may not persist in
their refusal. The situation in the meantime is one of extreme
gravity. The people are very excited, and the soldiers
mutinous. Without doubt it is now a question of European life
and property being in danger here. The French and Russians are
landing 100 men each. French, Russian, and United States'
Ministers, and myself, were deputed to-day at a meeting of the
foreign Representatives to declare to the Tsung-li Yamên that
the foreign Representatives must immediately bring up guards
for the protection of the lives of Europeans in Peking in view
of the serious situation and untrustworthiness of the Chinese
troops. That the number would be small if facilities were
granted, but it must be augmented should they be refused, and
serious consequences might result for the Chinese Government
in the latter event. In reply, the Yamên stated that no
definite reply could be given until to-morrow afternoon, as
the Prince was at the Summer Palace. As the Summer Palace is
within an hour's ride we refused to admit the impossibility of
prompt communication and decision, and repeated the warning
already given of the serious consequences which would result
if the Viceroy at Tien-tsin did not receive instructions this
evening in order that the guards might be enabled to arrive
here to-morrow. The danger will be greatest on Friday, which
is a Chinese festival."
"May 31.
Provided that the number does not exceed that of thirty for
each Legation, as on the last occasion, the Yamên have given
their consent to the guards coming to Peking. … It was decided
this morning, at a meeting of the foreign Representatives, to
at once bring up the guards that are ready. These probably
include the British, American, Italian, and Japanese."
"June 1.
British, American, Italian, Russian, French and Japanese
guards arrived yesterday. Facilities were given, and there
were no disturbances. Our detachment consists of three
officers and seventy-five men, and a machine gun."
"June 2.
The city is comparatively quiet, but murders of Christian
converts and the destruction of missionary property in
outlying districts occur every day, and the situation still
remains serious. The situation at the Palace is, I learn from
a reliable authority, very strained. The Empress-Dowager does
not dare to put down the Boxers, although wishing to do so, on
account of the support given them by Prince Tuan, father of
the hereditary Prince, and other conservative Manchus, and
also because of their numbers. Thirty Europeans, most of whom
were Belgians, fled from Paoting-fu via the river to
Tien-tsin. About 20 miles from Tien-tsin they were attacked by
Boxers.
{111}
A party of Europeans having gone to their rescue from
Tien-tsin severe fighting ensued, in which a large number of
Boxers were killed. Nine of the party are still missing,
including one lady. The rest have been brought into Tien-tsin.
The Russian Minister, who came to see me to-day, said he
thought it most imperative that the foreign Representatives
should be prepared for all eventualities, though he had no
news confirming the above report. He said he had been
authorized by his Government to support any Chinese authority
at Peking which was able and willing to maintain order in case
the Government collapsed."
"June 4.
I am informed by a Chinese courier who arrived to-day from
Yung-Ching, 40 miles south of Peking, that on the 1st June the
Church of England Mission at that place was attacked by the
Boxers. He states that one missionary, Mr. Robinson, was
murdered, and that he saw his body, and that another, Mr.
Norman, was carried off by the Boxers. I am insisting on the
Chinese authorities taking immediate measures to effect his
rescue. Present situation at Peking is such that we may at any
time be besieged here with the railway and telegraph lines
cut. In the event of this occurring, I beg your Lordship will
cause urgent instructions to be sent to Admiral Seymour to
consult with the officers commanding the other foreign
squadrons now at Taku to take concerted measures for our
relief. The above was agreed to at a meeting held to-day by
the foreign Representatives, and a similar telegram was sent
to their respective Governments by the Ministers of Austria,
Italy, Germany, France, Japan, Russia, and the United States,
all of whom have ships at Taku and guards here. The telegram
was proposed by the French Minister and carried unanimously.
It is difficult to say whether the situation is as grave as
the latter supposes, but the apathy of the Chinese Government
makes it very serious."
"June 5.
I went this afternoon to the Yamên to inquire of the Ministers
personally what steps the Chinese Government proposed to take
to effect the punishment of Mr. Robinson's murderers and the
release of Mr. Norman. I was informed by the Ministers that
the Viceroy was the responsible person, that they had
telegraphed to him to send troops to the spot, and that that
was all they were able to do in the matter. They did not
express regret or show the least anxiety to effect the relief
of the imprisoned man, and they displayed the greatest
indifference during the interview. I informed them that the
Chinese Government would be held responsible by Her Majesty's
Government for the criminal apathy which had brought about
this disgraceful state of affairs. I then demanded an
interview with Prince Ching, which is fixed for to-morrow, as
I found it useless to discuss the matter with the Yamên. This
afternoon I had an interview with the Prince and Ministers of
the Yamên. They expressed much regret at the murder of Messrs.
Robinson and Norman, and their tone was fully satisfactory in
this respect. … No attempt was made by the Prince to defend
the Chinese Government, nor to deny what I had said. He could
say nothing to reassure me as to the safety of the city, and
admitted that the Government was reluctant to deal harshly
with the movement, which, owing to its anti-foreign character,
was popular. He stated that they were bringing 6,000 soldiers
from near Tien-tsin for the protection of the railway, but it
was evident that he doubted whether they would be allowed to
fire on the Boxers except in the defence of Government
property, or if authorized whether they would obey. He gave me
to understand, without saying so directly, that he has
entirely failed to induce the Court to accept his own views as
to the danger of inaction. It was clear, in fact, that the Yamên
wished me to understand that the situation was most serious,
and that, owing to the influence of ignorant advisers with the
Empress-Dowager, they were powerless to remedy it."
"June 6.
Since the interview with the Yamên reported in my preceding
telegram I have seen several of my colleagues. I find they all
agree that, owing to the now evident sympathy of the
Empress-Dowager and the more conservative of her advisers with
the anti-foreign movement, the situation is rapidly growing
more serious. Should there be no change in the attitude of the
Empress, a rising in the city, ending in anarchy, which may
produce rebellion in the provinces, will be the result,
'failing an armed occupation of Peking by one or more of the
Powers.' Our ordinary means of pressure on the Chinese
Government fail, as the Yamên is, by general consent, and
their own admission, powerless to persuade the Court to take
serious measures of repression. Direct representations to the
Emperor and Dowager-Empress from the Corps Diplomatique at a
special audience seems to be the only remaining chance of
impressing the Court."
"June 7.
There is a long Decree in the 'Gazette' which ascribes the
recent trouble to the favour shown to converts in law suits
and the admission to their ranks of bad characters. It states
that the Boxers, who are the objects of the Throne's sympathy
equally with the converts, have made use of the anti-Christian
feeling aroused by these causes, and that bad characters among
them have destroyed chapels and railways which are the
property of the State. Unless the ringleaders among such bad
characters are now surrendered by the Boxers they will be
dealt with as disloyal subjects, and will be exterminated.
Authorization will be given to the Generals to effect arrests,
exercising discrimination between leaders and their followers.
It is probable that the above Decree represents a compromise
between the conflicting opinions which exist at Court. The
general tone is most unsatisfactory, though the effect may be
good if severe measures are actually taken. The general
lenient tone, the absence of reference to the murder of
missionaries, and the justification of the proceedings of the
Boxers by the misconduct of Christian converts are all
dangerous factors in the case."
"June 8.
A very bad effect has been produced by the Decree reported in
my immediately preceding telegram. There is no prohibition of
the Boxers drilling, which they now openly do in the houses of
the Manchu nobility and in the temples. This Legation is full
of British refugees, mostly women and children, and the London
and Church of England Missions have been abandoned. I trust
that the instructions requested in my telegrams of the 4th and
5th instant have been sent to the Admiral. I have received the
following telegram, dated noon to-day, from Her Majesty's Consul
at Tien-tsin:
{112}
'By now the Boxers must be near Yang-tsun. Last night the
bridge, which is outside that station, was seen to be on fire.
General Nieh's forces are being withdrawn to Lutai, and 1,500
of them have already passed through by railway. There are now
at Yang-tsun an engine and trucks ready to take 2,000 more
men.' Lutai lies on the other side of Tien-tsin, and at some
distance. Should this information be correct, it means that an
attempt to protect Peking has been abandoned by the only force
on which the Yamên profess to place any reliance. The 6,000
men mentioned in my telegram
of the 5th instant were commanded by General Nieh."
"During the night of the 14th inst. news was received that all
railway-carriages and other rolling stock had been ordered to
be sent up the line for the purpose of bringing down a Chinese
army to Tong-ku. On receipt of this serious information a
council of Admirals was summoned by Vice-Admiral Hiltebrandt,
Commander-in-Chief of the Russian Squadron, and the German,
French, United States Admirals, myself, and the Senior
Officers of Italy, Austria, and Japan attended; and it was
decided to send immediate orders to the captains of the allied
vessels in the Peiho River (three Russian, two German, one
United States, one Japanese, one British—'Algerine') to
prevent any railway plant being taken away from Tong-ku, or
the Chinese army reaching that place, which would cut off our
communication with Tientsin; and in the event of either being
attempted they were to use force to prevent it, and to destroy
the Taku Forts. By the evening, and during the night of 15th
inst., information arrived that the mouth of the Peiho River
was being protected by electric mines. On receipt of this,
another council composed of the same naval officers was held
in the forenoon of 16th June on board the 'Rossia,' and in
consequence of the gravity of the situation, and information
having also arrived that the forts were being provisioned and
reinforced, immediate notice was sent to the Viceroy of Chili
at Tientsin and the commandant of the forts that, in
consequence of the danger to our forces up the river, at
Tientsin, and on the march to Peking by the action of the
Chinese authorities, we proposed to temporarily occupy the
Taku Forts, with or without their good will, at 2 a.m. on the
17th inst." Early on Sunday, 17th June, "the Taku Forts opened
fire on the allied ships in the Peiho River, which continued
almost without intermission until 6.30 a.m., when all firing
had practically ceased and the Taku Forts were stormed and in
the hands of the Allied Powers, allowing of free communication
with Tientsin by water, and rail when the latter is repaired."
{113}
"Similar decrees on the 14th and 15th show alarm at the result
of the 'Boxer' agitation and lawlessness within the city.
Nothing so strong against the 'Boxers' had previously been
published. Fires were approaching too Closely to the Imperial
Palace. No steps had been taken by the Court to prevent the
massacre and burning of Christians and their property in the
country, but on the 16th the great Chien Mên gate fronting the
Palace had been burned and the smoke had swept over the
Imperial Courts. Yet even in these decrees leniency is shown
to the 'Boxers,' for they are not to be fired upon, but are,
if guilty, to be arrested and executed. On June 17th the edict
expresses the belief of the Throne that:—'All foreign
Ministers ought to be really protected. If the Ministers and
their families wish to go for a time to Tien-tsin, they must
be protected on the way. But the railroad is not now in
working order. If they go by the cart road it will be
difficult, and there is fear that perfect protection cannot be
offered. They would do better, therefore, to abide here in
peace as heretofore and wait till the railroad is repaired,
and then act as circumstances render expedient.'
{114}