Zoom Level Shortcode

New home Forums Basic Version Zoom Level Shortcode

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #71446
    kemmieg
    Participant

    I have a map and I’m wanting to put the map on different pages but only show certain map pin categories on these particular page maps. I don’t want to zoom into a certain pin I just want the map to zoom and center. When I put the shortcode in and just add the zoom level it moves the center of the map to the middle of the ocean. I’ve tried a bunch of different zoom levels but non of them zoom correctly. Is there a way to zoom and center with the shortcode and not focus on a single map pin?

    #71452
    Steven
    Moderator

    Hi there,

    Thank you so much for getting in touch, we really appreciate your time.

    Unfortuantely, this cannot presently be done with shortcodes, however, this can be achieved with some custom JavaScript.

    You should simply be able to copy the below script and paste this in the custom JS field via Maps -> Settings -> Advanced Settings -> Custom JS:

    jQuery(function($){
        jQuery(document.body).on('init.wpgmza', function(){
            WPGMZA.getMapByID(1).setZoom(3);
            WPGMZA.getMapByID(1).setCenter(new WPGMZA.LatLng(38.02539121763232, -96.42361268495252));
        });
    });

    Kindly adjust the map ID from 1 to the required map id. Simply copy the script and past once more and apply a different map id along with different values for the zoom level and the center coordinates.

    Kindly let me know if this helps?

    Kindest Regards,
    Steven De Beer

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.