-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4418826
By: deborra
Greetings,
I'm trying to transform the existing GoogleMaps demo to a Java version with some slight added function, including supporting more than one type of icon....
Is there a way for me to associate a Gmarker object with an specific image file?
Thanks much,
Deborra
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4420780
By: waterbottle
Hi,
"ZKForge - GMapsZ" hasn't implemented GIcon on GMarker in this version.
/Dennis
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4463820
By: henrichen
Please download the zk-GMaps-2.0_4 release. Check Gmarker's iconXxx attributes.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4464970
By: jojovelas2005
I am getting error when I tried to setIconImage within my java code:
Cause: Unknown exception: java.lang.NullPointerException.
java.lang.NullPointerException
at org.zkforge.gmaps.Gmarker.encodeURL(Gmarker.java:550)
at org.zkforge.gmaps.Gmarker.setIconImage(Gmarker.java:258)
I simply add this to my existing program:
public class EquipmentGmap extends Gmaps { ..
..
..
Gmarker marker = new Gmarker();
marker.setIconImage("http://www.google.com/mapfiles/markerZ.png");
.
.
marker.setParent(this);
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4465633
By: henrichen
Try setParent() first.
marker.setParent(this);
marker.setIconImage("http://www.google.com/mapfiles/markerZ.png");
It is a bug. Please follow this tracker.
http://sourceforge.net/tracker/index.php?func=detail&aid=1774421&group_id=156140
&atid=798590
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4465812
By: henrichen
The bug is fixed.
You can download the zk-GMaps-2.0_4_1.zip and try again. Note that this version needs you to upgrade to ZK 2.5 Freshly.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4465886
By: jojovelas2005
Thanks...I tested and it is now fixed using 2.5 FL and 2.0_4_1 gmaps.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4467070
By: jojovelas2005
Hi,
I still have problem with setIconImage during window invalidate(). It is defaulting to red tear icon when I called win.invalidate(). But when I refresh the page, it shows the correct IconImage.
My code has a search button that will simply create a new map locations. When clicked, button will call my win.invalidate() statement and I found no problem with my listbox and gmaps components. My listbox able to show new records while gmaps placement of icons (lat, long) are all correct except that IconImage is defaulted to red tear icon instead of my defined Icon.
I prepared to use invalidate (by components) instead of Executions.sendRedirect (refreshing page).
Is this a bug or a Google API issue?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4467931
By: henrichen
Please provide sample codes that will replicate your issue so I can test it here. Thanks.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4469558
By: jojovelas2005
Here are my codes:
There are two zul files mainpage.zul and locationreport.zul. Three java classes EquipmentGmap,LocationListBox, and MainWindow. This is just a simple test but this is what I want to happen in my current codes that invalidate() will able to show the correct IConImage.
Inside locationreport.zul there are two buttons that you can test. Button1 and Button2 will create different map locations notice that the icon is defaulting to red tear icon instead of markZ icon. The only time that markZ icon will appear correctly when you refresh the page.
Hope this will help.
Narge
mainpage.zul
--------------------------------------------------------------
<?page id="mainpage" ?>
<window id="mainWin" style="margin: 0 auto;" width="800px"
xmlns:h="http://www.w3.org/1999/xhtml">
<!-- main -->
<div align="top">
<vbox width="922px" spacing="0em">
<include id="stat" src="locationreport.zul"/>
</vbox>
</div>
</window>
---------------------------------------------------------------
locationreport.zul
<?page id="locationpage" ?>
<window id="locationreportWin"
xmlns:h="http://www.w3.org/1999/xhtml" use="com.maps.keys.MainWindow" width="100%"
xmlns:y="http://www.zkoss.org/2007/yui">
<script src="http://maps.google.com/maps?file=api&v=2&key=%{desktopScope
.gmapsKey}"
type="text/javascript" unless="${empty desktopScope.gmapsKey}"/> <zscript> String[] locations = new String[3]; Session sessionscope = Sessions.getCurrent();
void testbutton1() {
locations = new String[3];
locations[0]="0";
locations[1]="60";
locations[2]="-155";
sessionscope.setAttribute("locations",locations);
Window wind = (Window) Path.getComponent("//mainpage/mainWin");
wind.invalidate();
}
void testbutton2() {
locations = new String[3];
locations[0]="0";
locations[1]="50";
locations[2]="-122";
sessionscope.setAttribute("locations",locations);
Window wind = (Window) Path.getComponent("//mainpage/mainWin");
wind.invalidate();
}
</zscript>
<hbox spacing="0">
<vbox height="400px" style="Margin-left:2px;border:2px solid #3366cc;background:#4d607b;">
<separator spacing="2px"/>
<vbox id="searchWin" style="Margin-left:4px;border:2px solid #3366cc;background:#e1e9fb" width="200px">
<separator spacing="2px"/>
<hbox style='Margin-left:2px'>
<button label="Button 1" onClick="testbutton1()"/>
<button label="Button 2" onClick="testbutton2()"/>
</hbox>
<separator spacing="1em"/>
</vbox>
<vbox width="400px" style='Margin-left:2px;Margin-right:2px' id="statusbox" >
<listbox id="lstbox" width="500px" height="300px" mold="paging"
use="com.tracking.components.LocationListBox" rows="5">
<listhead style='Margin-left:2px;background:#e1e9fb;'>
<listheader label="" sort="auto" width="0px" visible="false"/> <!-- always place in 1st column -->
<listheader label="LATITUDE"
style="white-space:nowrap;background:#e1e9fb;font-weight:bold"/>
<listheader label="LONGTITUDE"
style="white-space:nowrap;background:#e1e9fb;font-weight:bold"/>
</listhead>
</listbox>
</vbox>
</vbox>
<splitter collapse="before"/>
<vbox visible="true" id="googlemaps" height="400px"
style="Margin-left:2px;border:2px solid #3366cc;background:#e1e9fb;">
<label value="Google Maps"
sclass="label1"/>
<div align="top">
<gmaps id="mymaps" width="400px" height="350px" showSmallCtrl="true"
use="com.tracking.components.EquipmentGmap">
<attribute name="onMapClick">
Gmarker gmarker = event.getGmarker();
if (gmarker != null) {
gmarker.setOpen(true);
}
</attribute>
</gmaps>
</div>
</vbox>
</hbox>
</window>
---------------------------------------------------------
Java class:
EquipmentGMap Class
------------------------------
package com.tracking.components;
import java.util.List;
import org.zkforge.gmaps.Gmaps;
import org.zkforge.gmaps.Gmarker;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zul.Window;
public class EquipmentGmap extends Gmaps {
private Session sessionscope;
private String[] locations;
public EquipmentGmap() {
}
public void removeMapComponent() {
List lst = this.getChildren();
int i = 0;
while(this.getChildren().size()>0) {
Gmarker gmark = new Gmarker();
if(this.getChildren().get(i).getClass() == Gmarker.class) {
i=0;
gmark=(Gmarker)this.getChildren().get(i);
gmark.detach();
}else {
i=i+1;
}
}
}
public void showCurrentMapAttribute(String lat,String lon) {
this.setShowTypeCtrl(true);
this.setCenter(Double.valueOf(lat), Double.valueOf(lon));
this.setZoom(2);
}
public void showComponents() {
Window win = new Window();
win = (Window)this.getRoot();
win.getFellow("googlemaps").setVisible(true); //do not edit line
this.setZoom(1);
}
public void onCreate() {
sessionscope = Sessions.getCurrent();
if(sessionscope.getAttribute("locations")!=null) {
locations=(String[])sessionscope.getAttribute("locations");
removeMapComponent();
showComponents();
Gmarker marker = new Gmarker();
marker.setId(locations[0]);
marker.setLat(Double.valueOf(locations[1]));
marker.setLng(Double.valueOf(locations[2]));
marker.setContent(
"THIS IS JUST A TEST FOR ID:"+locations[0]+ "<BR>" +
"For Lat/Long :"+locations[1]+"/"+locations[2]
);
marker.setIconImage("http://www.google.com/mapfiles/markerZ.png");
marker.setParent(this);
showCurrentMapAttribute(locations[1],locations[2]);
}
}
}
LocationListBox.class
---------------------------------------
package com.tracking.components;
import org.zkforge.gmaps.Gmarker;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Vbox;
import org.zkoss.zul.Window;
public class LocationListBox extends Listbox {
private Window window = new Window();
private String searchfound=" ";
private Session sessionscope;
private String style="white-space:nowrap;";
private String[] locations;
public void removeItems() {
this.clearSelection();
}
public void onCreate() {
window=(Window)this.getRoot();
sessionscope = Sessions.getCurrent();
if(sessionscope.getAttribute("locations")!=null) {
locations=(String[])sessionscope.getAttribute("locations");
this.setStyle(style);
Listitem item = new Listitem();
Listcell cell = new Listcell();
removeItems(); //remove current lists
// marker id
cell = new Listcell();
cell.setVisible(false);
cell.setLabel(locations[0]);
cell.setParent(item);
// latitude
cell = new Listcell();
cell.setLabel(locations[1]);
cell.setParent(item);
// longtitude
cell = new Listcell();
cell.setLabel(locations[2]);
cell.setParent(item);
item.setParent(this);
}// end while
showComponents();
}
public void showComponents() {
Vbox vbox = new Vbox();
vbox=(Vbox)window.getFellow("statusbox"); // do not edit line
vbox.setVisible(true);
this.setVisible(true);
}
public void onSelect() {
Listitem lstitem=(Listitem)this.getSelectedItem();
Listcell cellitem=(Listcell)lstitem.getChildren().get(1);
String itemLat=cellitem.getLabel().toString();
cellitem=(Listcell)lstitem.getChildren().get(2);
String itemLon=cellitem.getLabel().toString();
cellitem=(Listcell)lstitem.getChildren().get(0);
String itemId=cellitem.getLabel().toString();
Gmarker mark = new Gmarker();
mark=(Gmarker)window.getFellow("googlemaps").getFellow("mymaps").getFellow(ite
mId);
mark.setOpen(true);
}
}
MainWindow class:
----------------------------------
package com.maps.keys;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Window;
public class MainWindow extends Window {
public MainWindow() {
//We have to decide the key of Google Maps since we have a demo using it.
//This key is used by zkdemo/userguide/index.zul to generate a proper script
final Execution exec = Executions.getCurrent();
final String sn = exec.getServerName();
final int sp = exec.getServerPort();
//To add more keys: http://www.google.com/apis/maps/signup.html
String gkey = null;
if (sn.indexOf("www.potix.com") >= 0) { // http://www.potix.com/
gkey = "ABQIAAAAmGxmYR57XDAbAumS9tV5fxRYCo_4ZGj_-54kHesWSk0nMkbs4xTpq0zo9O75_
ZqvsSLGY2YkC7jjNg";
} else if (sn.indexOf("www.zkoss.org") >= 0) { // http://www.zkoss.org/
gkey = "ABQIAAAAmGxmYR57XDAbAumS9tV5fxQXyylOlR69a1vFTcUcpV6DXdesOBSMEHfkewcSz
wEwBT7UzVx8ep8vjA";
} else if (sn.indexOf("zkoss.org") >= 0) { // http://www.zkoss.org/
gkey = "ABQIAAAAakIm31AXAvNGFHV8i1Tx8RSF4KLGEmvBsS1z1zAsQZvbQceuNRQBsm65qGaXp
TWjZsc2bl-hm2Vyfw";
} else if (sn.indexOf("localhost") >= 0) { //localhost
if (sp == 80) // http://localhost/
gkey = "ABQIAAAAmGxmYR57XDAbAumS9tV5fxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRUITTZ-rzs
yEVih16Hn3ApyUpSkA";
else if (sp == 8080) // http://localhost:8080
gkey = "ABQIAAAAmGxmYR57XDAbAumS9tV5fxTwM0brOpm-All5BF6PoaKBxRWWERSynObNOWSy
MNmLGAMZAO1WkDUubA";
else if (sp == 7799)
gkey = "ABQIAAAAmGxmYR57XDAbAumS9tV5fxTT6-Op-9nAQgn7qnDG0QjE8aldaBRU1BQK2ADN
WCt1BR2yg4ghOM6YIA";
}
if (gkey != null)
exec.getDesktop().setAttribute("gmapsKey", gkey);
}
}
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4471680
By: henrichen
Your sample code is too complex. Can you provide codes that's just "enough"
to replicate your issue?
/henri
Asked: 2007-07-17 22:04:26 +0800
Seen: 1,023 times
Last updated: Sep 22 '07