Custom CSS & JS

The Custom CSS & JS section allows you to inject custom styles and scripts to extend or modify your map’s behavior and appearance.

PicPoints editor overview custom css and js

• Custom CSS

This tab allows you to add additional styling to your map elements or override existing ones. All styles added here are injected directly into a Shadow DOM. This means your custom styles are strictly isolated, they will only affect the map elements and will never conflict with your WordPress site’s global theme styles.

Examples of Usage

1. Adding a Border to Markers

You can target specific map element classes to alter their default look, such as adding a clean white outline to your markers:

.pp-layer.pp-marker {
  border: 4px solid #fff;
}

2. Modifying Tooltip and Popup Animations

You can completely customize entry and exit transitions for popups and tooltips. For more advanced effects, you can easily integrate keyframes or styles from external animation libraries like Animate.css:

.pp-tooltip, .pp-popup {
  transition: all .3s ease;
  opacity: 0;
  transform: scale(0.5);
  
  &.pp-show {
    opacity: 1;
    transform: scale(1);
  }
  
  &.pp-hide {
    opacity: 0;
    transform: scale(0.5);
  }
}

By utilizing the Custom CSS feature, you gain full granular control over the visual presentation of your map. Whether you need subtle design tweaks, brand-specific color matching, or advanced interactive animations, the isolated Shadow DOM architecture ensures your changes remain safe, performant, and completely independent of external website updates.

• Custom JS

The Custom JS tab allows you to execute custom JavaScript code to extend your map’s functionality, listen to events, or integrate with third-party tools.

Your custom script runs inside a dedicated function context. You can access the core map instance using two identical methods: the "mapApi" object or the context of the function (it’s bound to the map instance too).

console.log(mapApi);
console.log(this);

Examples of Usage

1. Triggering a Start Animation on Scroll

You can use the browser’s native IntersectionObserver API to track when the map becomes visible on the screen. This allows you to apply an entry animation class to the map elements, play it once, and then cleanly reset the state when it finishes.

Using this.viewportContainer, you can easily reference the container element of the current map instance:

const observer = new IntersectionObserver((entries, observer) => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      const container = this.viewportContainer;
      let timeoutId = null;
      
      container.addEventListener('animationend', function handler(e) {
        if (e.animationName === 'fx-flash') {
          clearTimeout(timeoutId);

          timeoutId = setTimeout(() => {
            container.classList.remove("animate");
            container.removeEventListener('animationend', handler);
          }, 500); 
        }
      })

      container.classList.add("animate");
      observer.unobserve(entry.target); 
    }
  });
}, {
  threshold: 0.1
});

observer.observe(this.viewportContainer);

The Custom JS feature provides developer-level programmatic control over the map ecosystem. By utilizing mapApi or this, you can create custom event listeners, dynamically manipulate layers, or link map interactions with external page elements.