• Resolved bardo

    (@bardo)


    Hello and thanks for the great plugin.

    I have a custom admin page where I need to put a map. I tried using do_shortcode('[wpgmza id="1"]'), which correctly prepares the html area, but the js I need (i.e. the part defining MYMAP) is not included.

    Checking the plugin source code I see that there are a few function doing it: wpgmaps_user_javascript_basic(), wp_admin_javascript_basic() and wpgmaps_admin_edit_marker_javascript(), but all of them have strict checks over the pages where they are used.

    Is this behavior intentional? Is there another way I’m not seeing to do this? Or a code snippet I can copy over to my widget to do it the same way?

    Thanks a lot,
    Corrado

    https://www.ads-software.com/plugins/wp-google-maps/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WPGMaps

    (@wpgmaps)

    Hi Corrado

    Yes, this would be normal behavior as the plugin loads specific JavaScript to the front end, and other JavaScript specific to the admin’s side.

    You could perhaps try changing the hook that uses the function wpgmaps_user_javascript_basic from wp_enqueue_scripts to admin_enqueue_scripts which will then load that JS in the admin’s panel instead of on the front end.

    Thread Starter bardo

    (@bardo)

    It works, thanks!

    For future reference, this is how to do it without touching the plugin:

    // Display a map if the wp-google-maps plugin is active
    if (function_exists('wpgmaps_user_javascript_basic')) {
      add_action('admin_footer', 'wpgmaps_user_javascript_basic');
      echo wpgmaps_tag_basic(array('id' => '1'));
    }
    Thread Starter bardo

    (@bardo)

    It works, thanks!

    For future reference, this is how to do it without touching the plugin:

    // Display a map if the wp-google-maps plugin is active
    if (function_exists('wpgmaps_user_javascript_basic')) {
      add_action('admin_footer', 'wpgmaps_user_javascript_basic');
      echo wpgmaps_tag_basic(array('id' => '1'));
    }
    Plugin Author WPGMaps

    (@wpgmaps)

    Hi there.

    So glad to hear! And thank you for posting the solution – we really appreciate it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Embedding a map in an admin page’ is closed to new replies.