-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have list of data (latitute and longitute) and need to plot multiple point or marker in google maps. this is the code, but it only mark 1 point. Any suggestion? please help me...
zul:
<gmaps id="courseMapViewMapForm" width="711px" height="500px" showsmallctrl="false"> <attribute name="onMapClick"> if (event.getReference() instanceof org.zkoss.gmaps.Gmarker) {
boolean open = !((org.zkoss.gmaps.Gmarker) event.getReference()) .isOpen(); event.getReference().setOpen(open); if (!open) courseMapViewMapForm.closeInfo(); } else {
} </attribute> <gpolyline id="routeMapPolyViewMapForm" color="#000000" weight="2"/>
<ginfo id="ginfoCreateMapForm"></ginfo> <gmarker id="gmarkerCreateMapForm" lat="3.124665835720851" lng="101.65848641430671"> </gmarker> </gmaps>
composer:
int counter = 0; double[] latitute = null; double[] longitute = null; String[] id = null; double latHist = 0; double longHist = 0; String idHist = null;
PDATrackingHistory pdaTrackingHist = new PDATrackingHistory();
if(!BaseUtil.isListNull(pdaTrackingHistoryList)){
int size = pdaTrackingHistoryList.size();
int nextLoc = size;
latitute = new double[nextLoc];
longitute = new double[nextLoc];
id = new String[nextLoc];
for(PDATrackingHistory hist : pdaTrackingHistoryList){
latHist = new Double (hist.getLatitude());
double a = latHist;
latitute[counter] = a;
longHist = new Double (hist.getLongitude());
longitute[counter] = longHist;
idHist = Long.toString(hist.getHistoryId()) ;
id[counter] = idHist;
counter = counter + 1;
pdaTrackingHist.setLatitude(hist.getLatitude());
pdaTrackingHist.setLongitude(hist.getLongitude());
pdaTrackingHistCreateMapArray.add(pdaTrackingHist);
}
countList = counter;
for (int m = 0; m < countList; m++) {
Gmarker marker = new Gmarker();
marker.setLat(latitute[m]);
marker.setLng(longitute[m]);
String infoString = "<div class=\"ginfobox\"><b>" + id[m] + "</b>"
+ "<br/>Latitude: " + latitute[m]
+ "<br/>Longitude: " + longitute[m] + "</div>";
marker.setContent(infoString);
marker.setParent(courseMapViewMapForm);
marker.setVisible(true);
markerListCreateMapForm.add(marker);
System.out.println("markerListCreateMapForm :"+markerListCreateMapForm.size());
} scaleMap(courseMapViewMapForm, gmarkerCreateMapForm); }
Hello saz,
By checking your code you can see the hard-coded coordinates.
Furthermore the markers that are generated by the loop will be pretty far away so you will not be able to see them (and they are integer values).
Finally please find below a very interesting application:
http://books.zkoss.org/wiki/ZKGettingStarted/CreatingaSimpleSightseeingApplication
Best Regards,
Darksu
Asked: 2015-07-10 07:34:05 +0800
Seen: 29 times
Last updated: Jul 12 '15