google maps - Open the gmapInfoWindow of a specific marker from the Managed Bean -
i have problem primefaces version 5.2. used gmap , gmapinfowindow. need managed bean open gmapinfowindow of specific marker.
here code
infowindow.xhtml
<h:form> <p:gmap id="gmap" center="36.890257,30.707417" zoom="13" type="hybrid" model="#{infowindowview.advancedmodel}" style="width:100%;height:400px"> <p:ajax event="overlayselect" listener="#{infowindowview.onmarkerselect}" /> <p:gmapinfowindow id="infowindow"> <p:outputpanel style="text-align: center; display: block; margin: auto"> <p:graphicimage name="/demo/images/antalya/#{infowindowview.marker.data}" height="150" /> <br /> <h:outputtext value="#{infowindowview.marker.title}" /> </p:outputpanel> </p:gmapinfowindow> </p:gmap> <!-- preload demo --> <p:outputpanel style="display:none"> <p:graphicimage name="/demo/images/antalya/konyaalti.png" /> <p:graphicimage name="/demo/images/antalya/ataturkparki.png" /> <p:graphicimage name="/demo/images/antalya/kaleici.png" /> <p:graphicimage name="/demo/images/antalya/karaalioglu.png" /> </p:outputpanel> </h:form>
and managedbean infowindowview.java
package org.primefaces.showcase.view.data.gmap; import java.io.serializable; import javax.annotation.postconstruct; import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import org.primefaces.event.map.overlayselectevent; import org.primefaces.model.map.defaultmapmodel; import org.primefaces.model.map.latlng; import org.primefaces.model.map.mapmodel; import org.primefaces.model.map.marker; @managedbean @viewscoped public class infowindowview implements serializable { private mapmodel advancedmodel; private marker marker; @postconstruct public void init() { advancedmodel = new defaultmapmodel(); //shared coordinates latlng coord1 = new latlng(36.879466, 30.667648); latlng coord2 = new latlng(36.883707, 30.689216); latlng coord3 = new latlng(36.879703, 30.706707); latlng coord4 = new latlng(36.885233, 30.702323); //icons , data advancedmodel.addoverlay(new marker(coord1, "konyaalti", "konyaalti.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png")); advancedmodel.addoverlay(new marker(coord2, "ataturk parki", "ataturkparki.png")); advancedmodel.addoverlay(new marker(coord4, "kaleici", "kaleici.png", "http://maps.google.com/mapfiles/ms/micons/pink-dot.png")); advancedmodel.addoverlay(new marker(coord3, "karaalioglu parki", "karaalioglu.png", "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png")); } public mapmodel getadvancedmodel() { return advancedmodel; } public void onmarkerselect(overlayselectevent event) { marker = (marker) event.getoverlay(); } public marker getmarker() { return marker; } }
Comments
Post a Comment