geometry functions & more!

Apart from the geomap widget, jQuery Geo comes bundled with functions to perform various operations on bounding boxes (a.k.a, bbox, the rectangle surrounding any geometry) and the geometries themselves. These functions (and two objects: WKT & proj) are all contained in the $.geo namespace.

geometry operations

Geometry isn't much fun if you can't do anything with it. These functions help you analyze and manipulate bounding boxes and GeoJSON geometry objects. You call them directly from the $.geo namespace, e.g.,:

$.geo.distance( point1, point2 )

Except for a few name changes and switching from an object-oriented API to a function-based one, jQuery Geo attempts to follow the names and behavior of the Java Topology Suite (JTS), which is the de-facto standard for geometry library APIs. JTS itself is an implementation of the OGC Simple Features specification but has made design decisions that improve the API for developers. The most notable of which is having Envelope (called bbox in jQuery Geo and GeoJSON) be its own class type.

bbox functions

These functions operate on GeoJSON bounding box array, i.e., a JavaScript array having four values:

geometry object functions

These functions operate on GeoJSON geometry objects: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. They do not operate on Feature or FeatureCollection objects, you have to call these functions on the geometry properties of Feature objects.

The geometry functions allow you to analyze relationships between geometries such as their distance apart as well as obtain information about them such as bounding box and center point, called the centroid. This section will eventually expand to cover all of the important spatial operations available in the Java Topology Suite.

WKT & proj objects

These two objects are also on the $.geo namespace. $.geo.WKT is a static object to convert between GeoJSON formatted JavaScript objects and well-known text. $.geo.proj is an instance of a Projection that, by default, can convert between geodetic coordinates (longitude, latitude) and web mercator which is an X/Y coordinate system commonly used on the web.

Please note the difference in case between the two objects on the $.geo namespace. $.geo.WKT is all upper-case because it is static and patterened after the HTML5 global object named JSON, while $.geo.proj can be modified and is closer in concept to an instance property of an Object type, e.g., how the jQuery $.callbacks object is an instance of the Callbacks type.

well-known text

While jQuery Geo uses JavaScript objects based on the GeoJSON spec, there are two commonly used formats to actually display those geometry objects as text: GeoJSON (i.e., the notation itself) and well-known text (WKT). The native JSON object helps you convert between JavaScript objects and GeoJSON. Our $.geo.WKT object helps you convert between JavaScript objects and WKT.


The $.geo namespace has a property named proj which is a JavaScript object having four functions: fromGeodetic, fromGeodeticPos, toGeodetic, and toGeodeticPos. These four functions allow all $.geo static bbox/geometry functions, geomap widget properties, geomap widget events & geomap widget methods (collectively referred to as plugin functions from now on) to work in geodetic (lon, lat) coordinates.