- JQuery - introduction, selections and methods
- Geospatial data on the web: GeoJSON
jQuery is a tiny JavaScript library that transforms the web into an entertaining experience
JavaScript is the language of the web, it is used to make the web look alive by adding motion to it
Features of JavaScript
jQuery is a fast, small, and feature-rich JavaScript library
It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers
There are two ways to install jQuery
DOM is a tree structure of the various HTML elements
DOM {Document Object Model} and is a mechanism for representing and interacting with your HTML, XHTML or XML documents
It allows you to navigate and manipulate your documents through a programming language, which in the browser will almost always be JavaScript
jQuery comes with a bunch of DOM related methods to manipulate DOM
DOM manipulation; getting and setting content text(), html() and val()
jQuery Selectors - used to select, manipulate HTML elements by using the $()
function & elements, ID's & classes
jQuery the $()
function replaces JavaScript functions such as
document.getElementById, querySelectorAll & getElementByClass
AJAX,- Asynchronous JavaScript And XML, allows you to load data in the background and display it on your webpage, without refreshing the page
Pros of using AJAX
Cons of using AJAX
One of the simplest and yet still powerful methods for loading data asynchronously is the load() method
You use it by selecting an element where you want the content loaded to and then call the load() method on it
It takes the URL that you wish to load, as a parameter
The jQuery get() and post() methods allows you to easily send a HTTP request to a page and get the result back
When you post a form, it's usually either a GET or a POST request, and with jQuery you can mimic that, since both a get() and a post() method exists
Same Origin Policy, which prevents us from making AJAX requests to a different domain or subdomain than the one currently executing the script
JSONP is a good solution to this
You can use GeoJSON within your main JavaScript code file, but, to keep your things looking simple, it's most common to maintain the GeoJSON in its own separate file
With Leaflet you have to define the GeoJSON as a JavaScript variable
L.geoJSON(...) expects all coordinates in the GeoJSON file to be WGS84 coordinates
If working with a GeoJSON file that uses a different projection (so without first reprojecting it to EPSG:4326), you can use the Proj4js Javascript library together with the Proj4Leaflet extension to enable support for coordinate reference systems not built into Leaflet
Queries about this Lesson, please send them to:
*References*
- Google Maps; Power Tools for Maximizing the API, 2014
Evangelos Petroutsos
- D3 Tips and Tricks; Interactive Data Visualization in a Web Browser, 2013
Malcolm Maclean
- Interactive Data Visualization for the Web, 2013
Scott Murray
- Web Programming with HTML5, CSS, and JavaScript, 2019
John Dean
- Leaflet Documentation
Leaflet Team
- Google Documentation for developers
Google Team
Courtesy of …