Gmaps"

From Documentation
(→‎Example: add properties / protocol, https://code.google.com/p/zkgmapsz/issues/detail?id=3)
(→‎Protocol: add issue link)
Line 87: Line 87:
  
 
Specify the protocol to load the Maps API. Currently it supports <tt>http</tt> for insecure connections and <tt>https</tt> for secure connections.
 
Specify the protocol to load the Maps API. Currently it supports <tt>http</tt> for insecure connections and <tt>https</tt> for secure connections.
 +
<!--
 +
https://code.google.com/p/zkgmapsz/issues/detail?id=3
 +
-->
  
 
=Supported Events=
 
=Supported Events=

Revision as of 08:20, 19 May 2014

Gmaps

  • Demonstration: Gmaps
  • Java API: N/A
  • JavaScript API: N/A
  • Style Guide: N/A

Employment/Purpose

Components: gmaps, ginfo, gmarker, gpolyline, gpolygon, gimage, and gscreen.

A gmaps is a maps component that wraps the famous Google Maps service that you can control it and embedded it in your ZK web application page in pure Java. Inside the gmap, you can manipulate your maps and add contents to the maps to create convenient locality related web application. You can add ginfo to represent an anchored information window for the maps. You can add multiple gmarkers to indicate a special location. You can add gpolyline and gpolygon to indicate a path or an area. You can also overlay gimage and gscreen to indicate very special places.

Example

ZKComRef Gmaps Example.png


source code for gmaps version 2.x
 <window title="Gmaps Demo" border="normal" width="520px">
	<script type="text/javascript" content="zk.googleAPIkey='Your-Google-API-Key'"/>

	<gmaps id="mymap" width="500px" height="300px" showSmallCtrl="true">
		<ginfo id="myinfo" open="true">
			<![CDATA[
				Hello, <a href="http://www.zkoss.org">ZK</a>.
			]]>
		</ginfo>
		
		<gmarker id="mymark" lat="37.4410" lng="-122.1490">
			<![CDATA[
				Hello, <a href="http://www.zkoss.org">ZK</a> on top of Gmarker.
			]]>
		</gmarker>
		
		<attribute name="onMapClick">
			Gmarker gmarker = event.getGmarker();
			if (gmarker != null) {
				gmarker.setOpen(true);
			}
		</attribute>
	</gmaps>
 </window>
source code for gmaps version 3.x
 <window title="Gmaps Demo" border="normal" width="520px">
	<!-- you may wish specify the version of google map api manually for some reason, 
		use version="[version]" to do it.
		ex: <gmaps version="3.5" id="mymap" ... /> -->
	<gmaps id="mymap" width="500px" height="300px" showSmallCtrl="true">
		<ginfo id="myinfo" open="true">
			<![CDATA[
				Hello, <a href="http://www.zkoss.org">ZK</a>.
			]]>
		</ginfo>
		
		<gmarker id="mymark" lat="37.4410" lng="-122.1490">
			<![CDATA[
				Hello, <a href="http://www.zkoss.org">ZK</a> on top of Gmarker.
			]]>
		</gmarker>
		
		<attribute name="onMapClick">
			Gmarker gmarker = event.getGmarker();
			if (gmarker != null) {
				gmarker.setOpen(true);
			}
		</attribute>
	</gmaps>
 </window>


Properties

Protocol

since 3.0.0

Specify the protocol to load the Maps API. Currently it supports http for insecure connections and https for secure connections.

Supported Events

Name
Event Type
onSelect
Event: SelectEvent

Notifies one that the user has selected a new item(can be Ginfo, Gpolyline, or Gpolygon) in the gmaps.

onInfoChange
Event: InfoChangeEvent

Notifies that the current open information window has changed(opened/closed)

onMapDrop
Event: MapDropEvent

Notifies that some component is dragged and dropped on the gmaps or gmarker component with latitude and longitude information.

onMapClick, onMapDoubleClick, onMapRightClick
Event: MapMouseEvent

Notifies that some mouse action has been applied on the gmaps or gmarker component with latitude and longitude information.

onMapMove
Event: MapMoveEvent

Notifies that the view center (latitude, longitude) of the gmaps has been moved.

onMapTypeChange
Event: MapTypeChangeEvent

Notifies that the map type of the gmaps has been changed.

onMapZoom
Event: MapZoomEvent

Notifies that the zoom level of the gmaps has been changed.

Work with MVVM

since 6.0.0

For work with ZK6 MVVM, it is required to create an addon xml and add the server annotation as follows:


( You can download the sample project [here] )

WEB-INF/gmapsz-bind-addon.xml

<?xml version="1.0" encoding="UTF-8"?>
<language-addon>
	<!-- The name of this addon. It must be unique -->
	<addon-name>gmapszbind</addon-name>
	<!-- Specifies what other addon this depends
	<depends></depends>
	-->
	<!-- Which language this addon will be added to -->
	<language-name>xul/html</language-name>
	<!-- Add bind annotation to gmaps -->
	<component>
		<component-name>gmaps</component-name>
		<extends>gmaps</extends>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>mapType</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapTypeChange</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>LOAD_REPLACEMENT</attribute-name>
				<attribute-value>mapType</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>LOAD_TYPE</attribute-name>
				<attribute-value>java.lang.String</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>selectedItem</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onSelect</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>LOAD_REPLACEMENT</attribute-name>
				<attribute-value>selectedItem</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>LOAD_TYPE</attribute-name>
				<attribute-value>org.zkoss.zk.ui.Component</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>lat</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>lng</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>zoom</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapZoom</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>neLat</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>neLng</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>swLat</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
		<annotation>
			<annotation-name>ZKBIND</annotation-name>
			<property-name>swLng</property-name>
			<attribute>
				<attribute-name>ACCESS</attribute-name>
				<attribute-value>both</attribute-value>
			</attribute>
			<attribute>
				<attribute-name>SAVE_EVENT</attribute-name>
				<attribute-value>onMapMove</attribute-value>
			</attribute>
		</annotation>
	</component>
</language-addon>

then add it into WEB-INF/zk.xml

<zk>
	<language-config>
		<addon-uri>/WEB-INF/gmapsz-bind-addon.xml</addon-uri>
	</language-config>
</zk>

Supported Children

* Ginfo,  Gmarker, Gpolyline, Gpolygon, Gimage, Gscreen

Use Cases

Version Description Example Location
     

Version History

Last Update : 2014/05/19


Version Date Content
     



Last Update : 2014/05/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.