WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] How can we control the zoom on Google Maps (9 posts)

  1. cjc1867
    Member
    Posted 9 months ago #

    Hi
    I want to show a map on an events page for one location but the Google Map is zoomed in way too far. It would be nice if it zoomed out at least 5 or 6 times.

    It would also be nice if you could control the zoom anyway within the plugin by the use of the shortcode.

    Thanks

    http://wordpress.org/plugins/events-manager/

  2. philipjohn
    Member
    Posted 9 months ago #

    Hiya,

    It's possible to set the zoom, but will require a little coding. This should get you going: http://wp-events-plugin.com/tutorials/modifying-event-location-google-maps/

    Thanks,
    Phil

  3. cjc1867
    Member
    Posted 9 months ago #

    Thanks for the link but I'm useless at javascript and jQuery.

    I have added this to header.php to see if I can get it to work:

    <script>
        jQuery( document ).ready(function( $ ) {
            jQuery(document).bind('em_maps_location_hook', function( e, map, infowindow, marker ){
    	    map.setZoom(10);
                map.setCenter(marker.getPosition());
            });
        });
    </script>

    Where have I gone wrong as it doesn't work?

    Thanks

  4. caimin_nwl
    NetWebLogic Support
    Posted 9 months ago #

    First thing is to make sure the function is actually firing when the page loads. Change the first two lines of code to this...

    <script>
        jQuery( document ).ready(function( $ ) {
    alert ("ok");

    ...keeping the rest of the code the same.

    When you load the page, do you see an alert box with OK in it?

  5. cjc1867
    Member
    Posted 9 months ago #

    Hi
    No it isn't firing and no alert box with the code below....

    <script>
        jQuery(document).ready(function ($) {
            jQuery(document).bind('em_maps_location_hook', function (e, map, infowindow, marker) {
                alert("OK");
                map.setZoom(10);
            });
        });
    </script>

    thanks

  6. caimin_nwl
    NetWebLogic Support
    Posted 9 months ago #

    What about if you put the alert code as the first line of the function, right before the bind function?

  7. cjc1867
    Member
    Posted 9 months ago #

    Hi
    If I add the alert before then yes it shows but it is not doing the bind function.

    I have had some success, I have added the code below to one of my themes js files.

    jQuery(document).bind('em_maps_location_hook', function (e, map, infowindow, marker) {
                map.setZoom(16);
      });

    This controls the shortcode [location post_id="58"] but not [locations_map country="UK"] so how do we control this one? Is there another hook?

    Thanks

  8. cjc1867
    Member
    Posted 9 months ago #

    Hi
    I'm on a roll now and found the other hook:

    jQuery(document).bind('em_maps_locations_hook', function (e, map, infowindow, marker) {
                map.setZoom(16);
      });

    I can now control the zoom even if the plugin is updated.

    Yipppeeeee

  9. getgolfed
    Member
    Posted 6 months ago #

    I know this is resolved but hoping cjc1867 is still receiving follow up emails.

    I added the code above to one of the js files in my customizr folder...still not getting anything. I have no clue what I'm doing...hoping somebody can put this in layman terms for me

Reply

You must log in to post.

About this Plugin

About this Topic