Viewing 8 replies - 1 through 8 (of 8 total)
  • Hiya,

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

    Thanks,
    Phil

    Thread Starter cjc1867

    (@cjc1867)

    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

    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?

    Thread Starter cjc1867

    (@cjc1867)

    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

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

    Thread Starter cjc1867

    (@cjc1867)

    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

    Thread Starter cjc1867

    (@cjc1867)

    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

    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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How can we control the zoom on Google Maps’ is closed to new replies.