Update gmap markers after onStateChange event

UI Components for JSF
Post Reply
ahoehn
Posts: 25
Joined: 04 Feb 2011, 14:27

17 Oct 2011, 19:39

Hi

I've got the problem that I want to update my gmap after a onStateChange with new markers if the lat&long has changed. I have a map where I want to show thousends of markers, for optimization I only want to show and add the markers to the MapModel which are actually viewable (depending on latitude & longitude).

Problem is that the following code creates an endless loop because on init the stateChange event is fired and it tries to update the map again and so on.

Code: Select all

<p:gmap id="map" center="36.890257,30.707417" zoom="13" type="HYBRID" model="#{mapBean.model}" style="width:600px;height:400px"> 
	        <p:ajax event="stateChange" listener="#{mapBean.onStateChange}" update="map"/>
</p:gmap>
How can I solve this problem correctly? Without update="map" the map is never refreshed with the new markers.

I use actually Primeface 3.0.M3, JSF2.1

Kind regards,
Adrian

dfraser
Posts: 3
Joined: 26 Aug 2011, 22:13

23 Nov 2011, 22:08

Hi! I'm having the exact same problem.

Primefaces 3.0.M4.

Trying to update the map after a stateChange event causes another stateChange event, leading to a loop.

I want to update the map markers when the zoom level or map position changes, and this is the only way I can see to do it.

Any ideas? Is this a bug?

The same technique worked in 2.2.1...

Thanks!
PrimeFaces 2.2.1 / JSF 2 / GlassFish 3.1

porthos
Posts: 122
Joined: 09 May 2011, 03:17

24 Nov 2011, 18:55

Does it still loop if you set fitBounds="false" on the gmap component?

PF3 M4 has fitBounds="true" by default, so this may be triggering the extra state change when it zooms to the extents of your new markers.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

dfraser
Posts: 3
Joined: 26 Aug 2011, 22:13

28 Nov 2011, 22:10

Thanks! fixBounds="false" has fixed the loop!

Now to properly deal with the missing-in-3.0 getCenter() :P
PrimeFaces 2.2.1 / JSF 2 / GlassFish 3.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests