🗺️
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. Developer

Custom Scripts

PreviousMapster Map Gravity Forms FieldNextHooks

Last updated 21 hours ago

Was this helpful?

Mapster WP Maps is built to allow developers to easily extend and tweak map display and settings. We have a huge number of ways you can hook into specific maps during runtime to execute functions and modify content. Custom Scripts is the simplest way to get developer access.

Custom Scripts are scripts you can write somewhere in the Javascript on your site, and then give to a specific map to call after it's done initializing. This is a simple way to hook into any given map and manipulate displays or controls as you need.

For any particular map, go to the Custom section. 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);

}

From here, make the modifications you need!