What is Gmapsz3?

Gmapsz3 component is a ZK component which wraps Google Maps’ API v3 into it so as to make it compatible within ZK in order to embed Google Maps in your own zul web pages. It has the same compatibility with ZK like that of Gmapsz-2.x, therefore, to upgrade to this version, please download the zip file of the new version and simply replace the old “gmapsz. jar” file with the new one.

 

Why use Gmapsz3?

  • Easy to use.
    When using Gmapsz3, this is all you need to write
     

    	
    		
    			
    			
    				
    				
    					<![CDATA[
    						Hello, Gmapsz is easy to use.
    						]]>
    					
    				
    			
    		
    	

    as opposed to what you need to write without using Gmapsz3

    					var map,
    						marker,
    						infowindow;
    
    					function updateMarkerAddress(str) {
    						document.getElementById('address').innerHTML = str;
    					}
    
    					function initialize() {
    						map = new google.maps.Map(document.getElementById('mapCanvas'), {
    							zoom: 19,
    							center: new google.maps.LatLng(37.44212147746187, -122.14311235847475),
    							mapTypeId: google.maps.MapTypeId.ROADMAP
    						});
    						marker = new google.maps.Marker({
    							position: new google.maps.LatLng(37.44182147746187, -122.14311235847475),
    							map: map
    						});
    						openInfo();
    					}
    					function openInfo(){
    						infowindow = new google.maps.InfoWindow({
    							content: 'Hello, Gmapsz is easy to use.',
    						});
    						infowindow.open(map, marker);
    					}
    					// Onload handler to fire off the app.
    					google.maps.event.addDomListener(window, 'load', initialize);
    	

    Please see full sample of pure html simple map at ZKfiddle

  • Highly interactive with other ZK Components
    Gmapsz3 Library is highly interactive with other ZK components under the ZK event handling system. For example, like the code below shows, users can easily hide/show markers by clicking the ZK button, users can set the content of the info window that belongs to its marker by entering in the ZK textbox, and users are allowed to open/close the info window by clicking the marker. 

    			
    				
    					org.zkoss.gmaps.Gmarker mkOne;
    				
    				
    				
    					
    						if (event.getReference() instanceof org.zkoss.gmaps.Gmarker) {
    							boolean open = !((org.zkoss.gmaps.Gmarker)event.getReference()).isOpen();
    							event.getReference().setOpen(open);
    							if (!open)
    								firstMap.closeInfo();
    						}
    					
    					
    				
    				
    				
    					
    						if (mkOne == null)
    							mkOne = firstMarker;
    						mkOne.setContent(self.value);
    					
    				
    			
    	

    Furthermore, components in Gmapsz3? library can be used in the ZK like all other ZK component to perform more complex applications.

Difference with Gmapsz-2.x:

Currently do not support:
– GScreen
– Drag between map items.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

11 Responses to “Gmapsz3 Library”

  1. GUL says:

    Very good component but I’ve a problem with markers.
    They don’t show up using my test page and also using the example above.

  2. benbai says:

    Hi GUL,
    thanks for giving it a try.

    The content was under maintenance,
    it should work now, please try again.

  3. zippy says:

    Hi, i upgrade gmaps component for 2,0,52 to 3.0 and the performance is awfull

    What can i do? the original gmaps says “api 3 is for mobile devices” but this is slower than api v2

  4. lorkan says:

    I have the same problem as GUL.
    After more less 2 weeks upgrade to v3, suddenly there’s no marker show up on map.
    I don’t understand why.

  5. ben says:

    It might related to the cache? You can try clear browser cache then try again.

  6. Antonio says:

    bug in Gmapsz3

    Class GmapsUtil

    Error java.lang.IndexOutOfBoundsException: Index: 1, Size: 0

    public static String getAddressByLatlng(double lat, double lng, boolean sensor, String language)
    /* */ throws ParseException, UnsupportedEncodingException, MalformedURLException, IOException
    /* */ {
    /* 225 */ StringBuilder sb = getGeocodeJsonResult(lat, lng, sensor, language);
    /* 226 */ String address = null;
    /* */
    /* 228 */ JSONArray results = (JSONArray)((JSONObject)new JSONParser().parse(sb.toString())).get(“results”);
    /* 229 */ address = (String)((JSONObject)results.get(1)).get(“formatted_address”); //if results size=0 then Error
    /* 230 */ return address; }

    Solution: Check results
    address = “”:
    if (results.size!=0) {
    address = (String)((JSONObject)results.get(1)).get(“formatted_address”);
    /* 230 */
    }
    return address;

  7. Ramiro says:

    Sometimes maps are shown partially, so i have to zoom out and then zoom in to fix it. Do you know what could be happening?

  8. Tomaž says:

    Is there a maven version. And is it compatible with ZK 6.5.2.

    If I try ZK 6.5.2 and

    org.zkoss.zkoss
    gmapsz
    2.0_7

    Everything breaks

    Regards

  9. Olga says:

    Hi, i upgrade gmaps component for 2.0.51 to 3.0.1 and I’ve a problem with enableGoogleBar: in the new version the search google bar doesn’t appear. Some notice about this ?

  10. Lisu says:

    Hi, what should I do, if I use Z3 and Google Maps Enterprise, can I set my own google maps server?

  11. Karthik says:

    Hi,

    Could we pass our own client id to google maps Server by using of ZK Gmap

Leave a Reply