map-created.tribe jQuery Event

Home Forums Calendar Products Events Calendar PRO map-created.tribe jQuery Event

  • This topic has 8 replies, 2 voices, and was last updated 8 years ago by Jason.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1495400
    Jason
    Participant

    Hi there,

    I’m trying to use the map-created.tribe event handler to change the zoom level on the map view (not single event view), since there is no option to change this. Here is what I have:

        jQuery( "body" ).on( "map-created.tribe", function( event, mapObj, mapEl, options, bounds ) {
            console.log( mapObj );
            mapObj.setZoom(16);
        });

    This changes the zoom level briefly but then it changes again (presumably based on markers and default coding).

    Any ideas on how I can set this zoom level?
    Thanks!

    #1496704

    Hi Jason,

    Thanks so much for reaching out!

    We do have a setting to change the default zoom level under Events Settings < General:

    Let me know if that helps!

     

    Thanks,

    Jaime

    #1497395
    Jason
    Participant

    Hi Jamie,

    That doesn’t help, unfortunately. That sets the zoom level for individual event maps. As indicated in my OP, I’m looking for the map event view (instead of list or calendar, etc). /events/map/ for example. I’ve seen in previous forum threads that what I’m asking for doesn’t exist, which is why I’m trying alternate methods.

    #1497400
    Jason
    Participant

    This reply is private.

    #1498415

    Hi Jason,

    Unfortunately this feature still doesn’t exist, but you can vote on this idea in our Feature Requests, as we tend to implement ideas based on customer feedback, so your input is greatly appreciated:

    https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/9858150-allow-an-initial-map-zoom-with-initial-centering-p

    If this functionality is a requirement for your intended project, I’d suggest that a third-party developer would be the best way to make this feature happen on a short timeline. ? We maintain a list of developers who work with our plugins on our Knowledgebase here:

    https://theeventscalendar.com/knowledgebase/find-a-customizer/

    Let me know if you have any other questions on this topic!

     

    Thanks,

    Jaime

    #1498417
    Jason
    Participant

    Jamie, I realize there’s no feature for that, which is why I was asking if anyone had used the map-created.tribe event handler. Per the tribe-events-ajax-maps.php…

    /**
     * Trigger a new event when the Map is created in order to allow Users option to customize the map by listening
     * to the correct event and having an instance of the Map variable avialable to modify if required.
     *
     * @param {Object} map An instance of the Google Map.
     * @param {Element} el The DOM Element where the map is attached.
     * @param {Object} options The initial set of options for the map.
     * @param {Object} bounds An instance with the bounds of the Map.
     *
     * @since 4.4.22
     */
    $( 'body' ).trigger( 'map-created.tribe', [ tg.map, mapEl, options, tg.bounds ] );

    This event fires when the map is created. I’m wondering if there’s a way to change the map after it’s created.

    This almost works…

    jQuery( "body" ).on( "map-created.tribe", function( event, mapObj, mapEl, options, bounds ) {
        console.log( mapObj );
        mapObj.setZoom(16);
    });

    …but like I said, it only changes briefly. Looking for ideas.

    #1498467
    Jason
    Participant

    For anyone that’s wondering how you can do something like this, I’ve figured it out.

    <script type="text/javascript">
        jQuery( "body" ).on( "map-created.tribe", function( event, map, mapEl, options, bounds ) {
            
            //Set counter
            let count = 1;
            
            //Listen for map tilesloaded, set the zoom, and increase the count so it doesn't happen again
            map.addListener('tilesloaded', function() {
                
                if ( count === 1) map.setZoom(16);
                count++;
                
            });
            
        });
    </script>
    • This reply was modified 8 years ago by Jason. Reason: Added script tags for prettier code
    #1498930

    Glad you were able to figure things out and thanks for sharing!

    You are welcome back in our support forums any time!

    Since this issue has been resolved, I am going to close this thread.

    Have a great weekend!

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘map-created.tribe jQuery Event’ is closed to new replies.