Please enable JavaScript.
Coggle requires JavaScript to display documents.
Web Mapping (The fundamental programming knowledge set for developing web…
Web Mapping
The fundamental programming knowledge set for developing web mapping applications
JavaScript
JavaScript libraries
JQuery
Leaflet
Cesium
Bootstrap
Major mapping and data visualization libraries
Can be both server-side & client-side
The most popular server-side JavaScript implementation is
NodeJS
Allows you to install Leaflet and Cesium and other libraries on the server-side
Main Uses
Create elements
Load and bind data
Modify element properties
Write functions
Listen for user interaction
Fundamentals
Objects
Have properties and values
e.g. Car make, weight, model, etc.
Variables
Holds data values
e.g. X = 2
Data types
Primitive
Boolean
: True or False
AND: True only if both values are true
OR: True if one or both are true
NOT: True if statement is false
Number
: Any integer or floating-point value
String
: Text characters that are delimited by quotes
Null
: Variable set to have the value of null. Populate later
Undefined
: Variable declared, but set to have no value
Reference
Array
[1, 3, 5] First position is 0, so array[1] would = 3
Object Literal
Comma separated list of name value pairs
Function
Placed within variables
myFunction runs the variable
Functions
Return Values
Computed values provided by the function
Received values that can be used later
Parameters vs Arguments :
Parameters
Placeholder for objects to be passed to the function when called
Can provide default values if no argument is received
Arguments
Real values of the objects, received as parameters for the function when invoked
Function Declarations
Declared by using keyword
function
Called upon later using keyword
Function Expression
Functions can be held in variables
Anonymous functions
Not required to have a name
Used a lot in web applications
Function Hoisting
A variable can be used before it is declared
It is "hoisted" to the top of the code snipet
Declare before use
Declare after use
Function expressions are not hoisted
Variable Scope
Two main types of variables
Local variables
Not useable after function ends
Global variables
Always useable if declared outside of function
Methods
Options and actions
e.g. a car (object) can start, stop, drive, brake. All are actions that can be performed using a function
e.g. car.start().
Properties and Values
Values associated with an object
e.g.
objectName.property
car.make = "Jeep"
To change a value:
Flow Control
Conditionals
if
...
else
statments
Run if TRUE, skip if FALSE
Loops
while
or
for
statements
For loop:
1st: Start value. 2nd: Where the loop will stop when value is FALSE. 3rd: Increment of the loop
While loop
Adds +1 to the counter each time
JSON
JavaScript Object Notation
JavaScript element
GeoJSON
Contains geometry
Accessing Elements
Document object
type
document
type
document.body
to see elements in the body
Access by DOM selectors
Event Listeners
Libraries
Pre-written JavaScript
For web mapping we will use 3 libraries
jQuery
Leaflet
Easy to use mapping library that makes web maps for displaying geospatial data
Cesium
A javascript library to make virtual global
Used for adding user interaction and making calls to other websites
Adding jQuery to your webpage is done by including the following line of code at the bottom of your body section
css
HTML