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.
-
AuthorPosts
-
April 3, 2018 at 9:16 am #1495400
Jason
ParticipantHi there,
I’m trying to use the
map-created.tribeevent 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!April 4, 2018 at 11:08 am #1496704Jaime Marchwinski
KeymasterHi 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
April 5, 2018 at 7:37 am #1497395Jason
ParticipantHi 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.April 5, 2018 at 7:37 am #1497400Jason
ParticipantThis reply is private.
April 6, 2018 at 4:23 am #1498415Jaime Marchwinski
KeymasterHi 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:
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
April 6, 2018 at 4:33 am #1498417Jason
ParticipantJamie, 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.
April 6, 2018 at 5:32 am #1498467Jason
ParticipantFor 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
April 6, 2018 at 10:38 am #1498930Jaime Marchwinski
KeymasterGlad 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!
-
This reply was modified 8 years ago by
-
AuthorPosts
- The topic ‘map-created.tribe jQuery Event’ is closed to new replies.
