primeface gmap

在primefaces中,封装了google map组件,使用非常方便。

1,在页面中(如xhtml)引入google map的JS

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

2,在页面使用gmap标签

<p:gmap id="gmap" center="#{storeManagerAction.latLngStr}" zoom="13"
	type="HYBRID" model="#{storeManagerAction.draggableModel}"
	style="width:600px;height:400px">
	<p:ajax event="markerDrag"
		listener="#{storeManagerAction.onMarkerDrag}" update="growl" />
</p:gmap>

3,后台Bean中属性方法定义

private MapModel draggableModel;

public void onMarkerDrag(MarkerDragEvent event)
{
	Marker marker = event.getMarker();
	store.setLatitude(marker.getLatlng().getLat());
	store.setLongitude(marker.getLatlng().getLng());
}

在使用<p:gmap标签时,它有一个type属性,该属性取值范围如下:

ROADMAP,用于显示默认的道路地图视图

SATELLITE,用于显示 Google 地球卫星图片

HYBRID,用于同时显示普通视图和卫星视图

TERRAIN,用于根据地形信息显示实际地图。

猜你喜欢

转载自boy-program.iteye.com/blog/2076128