voici le vidéo qui montre ca :
Ceci et le code de managedBean :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package beans; | |
import javax.faces.bean.ManagedBean; | |
import javax.faces.bean.SessionScoped; | |
import org.primefaces.model.map.DefaultMapModel; | |
import org.primefaces.model.map.LatLng; | |
import org.primefaces.model.map.MapModel; | |
import org.primefaces.model.map.Marker; | |
import org.primefaces.model.map.Polyline; | |
@ManagedBean | |
@SessionScoped | |
public class MapBean { | |
private MapModel rectangleModel; | |
Polyline polyline = new Polyline(); | |
private double lat=21.424191; | |
private double lng=39.813588; | |
private LatLng latlng=new LatLng(lat, lng); | |
public MapBean() { | |
rectangleModel = new DefaultMapModel(); | |
polyline.getPaths().add(latlng); | |
polyline.setStrokeWeight(5); | |
polyline.setStrokeColor("green"); | |
polyline.setStrokeOpacity(0.7); | |
Marker marker=new Marker(latlng); | |
rectangleModel.addOverlay(marker); | |
} | |
public MapModel getRectangleModel() { | |
return rectangleModel; | |
} | |
public void setRectangleModel(MapModel rectangleModel) { | |
this.rectangleModel = rectangleModel; | |
} | |
} |
Le code de la page geo.xhtml est le suivant :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:h="http://java.sun.com/jsf/html" | |
xmlns:f="http://java.sun.com/jsf/core" | |
xmlns:p="http://primefaces.org/ui" | |
xmlns:ui="http://java.sun.com/jsf/facelets"> | |
<h:head> | |
<script src="http://maps.google.com/maps/api/js?sensor=false" | |
type="text/javascript" ></script> | |
</h:head> | |
<body> | |
<p:panel header="gmap exemple"> | |
<h:form> | |
<p:gmap center="21.424191,39.813588" model="#{mapBean.rectangleModel}" zoom="8" type="hybrid" style="width:1000px;height:600px" ></p:gmap> | |
</h:form> | |
</p:panel> | |
</body> | |
</html> |
Le script suivant est obligatoire,sinon le map ne s'affiche pas .
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript">
</script>
quels sont les libs qu'on doit utiliser
ReplyDelete