Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)

#1 2011-12-02 03:53:38

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Action:resize - and other trigger methods

I think I made a mistake steering someone to using "resize" as an action. I know that triggering a resize is an important event to bind to window resize, or hidden tabs.

I was playing with gmap3 source today for first time and got a resize action working by adding "resize" to _noInit  array and a new gmap3 function:

this.resize=function( todo){
		google.maps.event.trigger( map, todo.action);
	}

This makes the following seem to work:

$('#map').css({width:300,height:300}).gmap3('resize')

// or

$(window).on('resize', function(){
         /// calcuate new window size
	$('#map').css({width:newW,height:newH}).gmap3('resize');						  
})

Am considering expanding this into a more robust trigger handler for other events. Am wondering if any changes need to be made to .data('gmap3') doing this.

Offline

Ads
(server costs 27.50€ per month)

#2 2011-12-02 07:42:54

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 469

Re: Action:resize - and other trigger methods

Yep,

I saw the posts about the triggering (i didn't know it)

I'm looking to write a more generic function "trigger"

Thanks again for your interest and support on this forum

JB

Offline

#3 2011-12-03 20:30:42

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 469

Re: Action:resize - and other trigger methods

What do you think of this kind of use :

            $div.slideDown('fast', function(){
              // short call
              $div.gmap3('trigger:resize');
              /*
              // or classical one
              $div.gmap3({action:'trigger', name:'resize'});
              */
            });

In this version, i add a simplified inline call

Offline

#4 2011-12-03 21:11:57

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: Action:resize - and other trigger methods

I like the idea of using "trigger" as a key as it will line up well with google API docs. The syntax may be a bit confusing if "trigger" is in a string but "action" is not.

Offline

#5 2011-12-04 18:06:17

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 469

Re: Action:resize - and other trigger methods

In fact,
trigger is not a pure string, the classical version is :

 $div.gmap3({action:'trigger', name:'resize'}); 

This second one should be a shorter version like in get or clear,
This new version just introduce a way to simplify the code when there is one parameter :

$div.gmap3('trigger:resize');

oO i have to update the documentation... i just saw that i didn't explain this kind of short code

$("#test").gmap3("clear");

And this should be used in get or clear functions to simplify :

$('#mapka').gmap3({action: 'clear', name:'directionrenderer'});

as

$('#mapka').gmap3('clear:directionrenderer');

Last edited by jbdemonte (2011-12-04 18:15:04)

Offline

#6 2011-12-04 20:29:54

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: Action:resize - and other trigger methods

That shortcode syntax is very convenient. I realize now that when I was trying to clear directions before I hadn't gotten into source much to look for "names" of actions. Past couple of weeks have been interesting ..trying to sort out V3 methods vs V2 and then using gmap3 to integrate.

I looked around again to see where the short code syntax is in docs but didn't see it. Is that new, or it works in 4.0-4.1?

Offline

#7 2011-12-05 21:05:05

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 469

Re: Action:resize - and other trigger methods

smile
the shortest :

$("#blablabla").gmap3("get");
// or
$("#blablabla").gmap3("clear");

it already exists when the only parameter is action but it is not yet documented (it really takes a lot of time !)

and this new version is a proposition to introduce a shorter write when there is one parameter

$('#mapka').gmap3('clear:directionrenderer');

Offline

#8 2011-12-05 23:30:30

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: Action:resize - and other trigger methods

OK, understood.

Can see how keeping documentation current, as well as keeping versions differences displayed in docs would be a lot of work. One thought, not sure if it is practical or not...  a public method developers could call on plugin to display available actions/triggers available in current version .

Something like : console.log( $.gmapActions())

Offline

#9 2011-12-10 18:48:07

jbdemonte
Administrator
From: Pourrières, France
Registered: 2011-11-21
Posts: 469

Re: Action:resize - and other trigger methods

I just commit trigger
For now, i didn't add the new shortest write.

Offline

#10 2011-12-10 19:33:53

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: Action:resize - and other trigger methods

are these updates available in current release now?

EDIT: I see it on Github

Offline

#11 2011-12-26 11:49:34

aidansilva
Member
From: 1617 Battle St, Webster, NH 03
Registered: 2011-12-26
Posts: 1

Re: Action:resize - and other trigger methods

Yes please let us know about the updates soon.

Offline

Board footer

Powered by FluxBB