0

plotting marker in gmap

asked 2015-07-10 07:34:05 +0800

saz gravatar image saz
1

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); }

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-12 14:38:17 +0800

Darksu gravatar image Darksu
1991 1 4

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-07-10 07:34:05 +0800

Seen: 29 times

Last updated: Jul 12 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More