google maps - How to refresh gmap markers in primefaces p:gmap after updating the gmap with new markers -


i have problem on project gmap component of primefaces 3.5 i'm using jsf2.0. have command button filtering on markers , important updates mapform

<h:form id="epsfilterform">       <p:commandbutton action="#{mapmb.filterprojects}" value="#{bundle['filter'] }" update=":mapform" /> </h:form> 

mapform:

<h:form id="mapform">   <p:gmap id="googlemap" center="48.849988,2.3805715" zoom="11"  type="terrain" fitbounds="false" model="#{mapmb.advancedmodel}"      widgetvar="wmap" style="width:1000px;height:700px;display: inline-block;" >      <p:ajax event="overlayselect"  listener="#{mapmb.onmarkerselect}" />        <p:gmapinfowindow>           <p:outputpanel style="text-align:center;display:block;margin:auto:">             <p:panelgrid columns="2" styleclass="infotable" >                  <p:outputlabel value="#{bundle['ep.operation.name'] }" />                 <p:outputlabel value="#{mapmb.selectedep.opname}" />             </p:panelgrid>         </p:outputpanel>       </p:gmapinfowindow>  </p:gmap> 

mapmb - scope - session scope populateadvancedmodel()

public void populateadvancedmodel(list<ep> eps) {     advancedmodel = new defaultmapmodel();     int count = 0;     marker marker;     (ep ep :eps) {         //advancedmodel.addoverlay(new marker(coord1, "konyaalti", "konyaalti.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));         system.out.println("integer.tostring(ep.getid()):"+integer.tostring(ep.getid()));         marker =  new marker(new latlng(  double.parsedouble(ep.getlatitude()) ,  double.parsedouble(ep.getlongitude())));         marker.settitle( integer.tostring(count));         advancedmodel.addoverlay(marker);         count++;     } } 

filterprojects()

public string filterprojects() {     //filtermb filtermb = (filtermb) jsfutil.getmanagedobject("filtermb");     eps = epdao.filtereps(client, architect, realizationtype, state, selectedcert);     populateadvancedmodel(eps);     return null; } 

onmarkerselect()

public void onmarkerselect(overlayselectevent event) {     marker marker = (marker) event.getoverlay();     string markertitle = marker.gettitle();     selectedep = eps.get(integer.parseint(markertitle)); } 

when load page first time ok. info (p:gmapinfowindow ) window loading , information ep variable there. when click command button in epsfilterform (that has input fields haven't posted here) map updated , filtered markers there , have title when hover on them, overlayselect event not working in same way. thing when page loading first time there initial script puts behavior on markers when refresh map initial script not running again , that's why when click on marker , overlayselect event fired have null pointer exception in onmarkerselect() method (marker null). important - working without problem on local server when deploy google app engine it's working described above.

the defaultmapmodel of gmap (referenced 'model' attribute in p:gmap element) has no proper functionality clear, unlike other model objects, e.g. eventmodel of p:schedule.

if provide object sessionscoped controller, if recreate object scratch, p:gmap reason keeping reference first mapmodel provided. practically means new/updated mapmodel objects not being used, except first one.

so, tricky point of gmap going updated (adding/removing markers, overlays etc) mapmodel object should retrieved requestscoped object.

now, option, iterating through markers. can find similar posts here. way can keep backing bean sessionscoped, again, not supposed create new mapmodel.

edit: i'm m getting impression view fails update markers, not mapmodel itself. anyway, solution same. it's can't drop bean scope request (e.g. fetching info window on overlayselect), end refreshing markers


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -