Join

Set MyListing Map Services Default Map Zoom to the Middle of the United States

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new JS code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

While this snippet uses the coordinates corresponding to the middle of the US, you can easily replace the coordinates with the location of your choice by editing Line 6.

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);
  }
});