14

How to Set Your MyListing Map’s Default Zoom to the Middle of the United States

Powered by WPCodeBox

Control how maps are displayed on your MyListing website with this code snippet. Easily set the default map zoom to the middle of the United States or customize the coordinates to any location of your choice. This MyListing map snippet provides greater control over your website’s map presentation.


/**
 * Author: MyListing Club
 * Author URI: https://mylisting.club
 */

jQuery(document).ready(function ($) {
  if ($(".location-field-wrapper .c27-map").length) {
    var mapZoom = setInterval(function () {
      if (MyListing.Maps.instances.length) {
        MyListing.Maps.instances.forEach((instance) => {
          instance.map.setCenter(["-97.922211", "39.381266"]); // starting position [long, lat]
          instance.map.setZoom(03);
        });
        clearInterval(mapZoom);
      }
    }, 500);
  }
});

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.