map

This file provides functions for working with maps.

Methods

inner createDefaultBaseMapLayers() → {Object.<String, Object>}

Initializes and returns a collection of default basemap layers. The function creates a set of base layers including CartoDB (both dark and light themes), and various Google Maps layers (Default Ingress Map, Roads, Roads with Traffic, Satellite, Hybrid, and Terrain).

Returns:
Object.<String, Object> -

An object containing different basemap layers ready to be added to a map. Each property of the object is a named map layer, with its value being the corresponding Leaflet tile layer object.

inner createDefaultOverlays() → {Object.<String, L.LayerGroup>}

Creates and returns the default overlay layers for the map. Sets up various overlay layers including portals, links, fields, and faction-specific layers.

Returns:
Object.<String, L.LayerGroup> -

An object containing overlay layers for portals, links, fields, and factions

inner getPosition() → {Object}

Retrieves the last known map position from the URL parameters or cookies. Prioritizes URL parameters over cookies. Extracts and normalizes the latitude, longitude, and zoom level.

Returns:
Object -

An object containing the map's position and zoom level, or undefined if not found.

inner normLL(lat, lng, zoom) → {Object}

Normalizes latitude, longitude, and zoom values. Ensures that the values are valid numbers, providing defaults if necessary.

Parameters:
Name Type Description
lat number | string

Latitude value or string that can be converted to a number.

lng number | string

Longitude value or string that can be converted to a number.

zoom number | string

Zoom level value or string that can be converted to a number.

Returns:
Object -

An object containing normalized center (latitude and longitude) and zoom level.

inner setupMap()

Initializes the Leaflet map and configures various map layers and event listeners. This function is responsible for setting up the base map, including the default basemap tiles (CartoDB, Default Ingress Map, Google Maps), and configuring the map's properties such as center, zoom, bounds, and renderer options. It also clears the 'Loading, please wait' message from the map container.

Important functionalities:

  • Adds dummy divs to Leaflet control areas to accommodate IITC UI elements.
  • Creates and adds base layers and overlays to the map.
  • Configures event listeners for map movements, including aborting pending requests and refreshing map data.
  • Manages cookies for map position and zoom level.
  • Handles the 'iitcLoaded' hook to set the initial map view and evaluate URL parameters for portal selection.