Converting JavaScript from Drupal 7 to Drupal 8 standards
As you already linked from the docs https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview I just repeat the most important parts here:

MYMODULE.libraries.yml

foobar:
  js:
    js/foobar.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupal
    - core/drupalSettings


js/foobar.js

(function ($, Drupal) {
  Drupal.behaviors.myModuleBehavior = {
    attach: function (context, settings) {
      $('.MYSELECTOR', context).once('myCustomBehavior').each(function () {
        // Apply the myCustomBehaviour effect to the elements only once.

        // I guess you have to pass something to `settings` first.
        // $("#mapplic").mapplic(settings.mapplic);

        console.log('Hello world!');
      });
    }
  };
})(jQuery, Drupal);


MYMODULE.module

function MYMODULE_page_attachments_alter(array &amp;$attachments) {
  $attachments['#attached']['library'][] =  'MYMODULE/foobar';
}




Update: removed some flaws.