🗺️
Mapster WP Maps
HomeProExamplesContact
  • Getting Started
    • About
    • Installation
    • Key Concepts
    • Importing/Exporting
    • Guides
      • Your First Map
      • Creating a Crowdsourced Map
      • Set Up Recurring Import
      • Adding a Custom Style
      • Building a Custom Popup
  • Creating Shapes
  • Displaying Maps
  • Maps
    • Map Tiles
    • Initial View
      • Fit to Features
      • Manual Values
      • User Location
    • Map Size
    • Points, Lines, Polygons
    • Clustering
    • Interactivity
    • Controls
      • Basic Controls
      • Geocoding & Geolocation
      • Togglers
      • Other Controls
      • Control Render Order
    • Filters
      • Category Filter
      • Custom Search Filter
      • Filter Dropdown
    • Lists
      • Store Locator
    • Specialty Maps
      • Map Comparer
      • Heatmaps
      • Elevation Profile
      • User Submission
      • Listing Page Map
    • Preloader
    • Developer
      • Javascript
      • Embedding Maps
      • Faster Loading (Cache)
      • Caching
      • Progressive Loading
  • Locations
    • Markers
    • Circles
    • Labels
    • Icons
    • 3D Models
  • Lines
    • Lines
  • Multi Lines
  • Polygons
    • Flat Polygons
    • 3D Polygons
    • Image Polygons
  • Multi Polygons
  • Popups
    • Popup Templates
      • Introduction
      • Layout, Colors, Text, CSS
      • HTML
      • Options
    • Popup Content
  • Pro Sections
    • User Submission
      • Overview
      • Submission Interface
      • Adding Custom Fields
      • Submission Admin
  • Mass Edit
  • Settings
    • General
    • Account Management
  • Advanced
  • Import
  • Tileset Management
  • Developer
    • Mapster Map ACF Field
    • Mapster Map Gravity Forms Field
    • Custom Scripts
    • Hooks
    • Spatial DB & API
    • Internationalization
Powered by GitBook
On this page

Was this helpful?

  1. Maps
  2. Developer

Javascript

Add a custom function.

PreviousDeveloperNextEmbedding Maps

Last updated 3 days ago

Was this helpful?

Here, you can add a Javascript function that should be run after the map has done initializing. This is a simple way to hook into any given map and manipulate displays or controls as you need.

If you need more advanced hooks with Javascript, check out the Developer section on .

Enter the name of a function here. For example, let's call our function "myCustomScript".

Create a global function with that script name. Your script will automatically receive a "map" and a "features" variable. For Maplibre and Mapbox, this will be a map object matching those libraries; for Google Maps, it'll be a map object matching the Google Maps API. As follows:

window.myCustomScript = function(map, features) {
	console.log(map);
	console.log(features);
}
hooks