Laman Utama Tanya Wiki English Artikel Komuniti E-Mel Ringtones Search

Bantuan | Carian | Ahli | Kalendar

Google

Selamat Datang ( Log In | Daftar )

 
Reply to this topicStart new topic
Netbeans 5.5 + Google Maps Api, proj tok jejak lrt. tp still x jd.. ada sape2 leh tlg x?
siWan
post Jun 4 2008, 08:50 PM
Kiriman #1


Ahli Baru


Grup: Learning
Kiriman: 6
Penyertaan: 4-June 08
Ahli ke- 48,335



assalamualaikum..
kpd senior2 & rakan2 sekalian..
leh x bantu ak jap..
aku kna wat website tok proj akhir.
proj ni tok jejak kat mane LRT pada masa-nyata mggunakan map google.
Guna dbase sendiri.
Xtau mane slh sbb Marker tu x kluar kat map.

leh tlg tgk x mane slh?

urgent ni..


/*
* idLRT.java
*
* Created on June 2, 2008, 1:07 PM
* Copyright user
*/
package lrt_tracker;

import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.j2ee.blueprints.ui.geocoder.GeoCoder;
import com.sun.j2ee.blueprints.ui.mapviewer.MapComponent;
import com.sun.j2ee.blueprints.ui.mapviewer.MapMarker;
import com.sun.j2ee.blueprints.ui.mapviewer.MapPoint;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Button;
import com.sun.rave.web.ui.component.DropDown;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Hyperlink;
import com.sun.rave.web.ui.component.ImageComponent;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.MessageGroup;
import com.sun.rave.web.ui.component.Page;
import com.sun.rave.web.ui.model.SingleSelectOptionsList;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Vector;
import javax.faces.FacesException;
import javax.faces.convert.LongConverter;
import javax.faces.event.ValueChangeEvent;


public class idLRT extends AbstractPageBean {

private int __placeholder;

private double latitude;

private double longitude;

private String id;

private Vector<Object> line1;

private Vector<Object> lat1;

private Vector<Object> log1;

private double log;

private double lat;

private String lines;


private void _init() throws Exception {
lokasi_lrtDataProvider.setCachedRowSet((javax.sql.rowset.Cac
hedRowSet)getValue("#{SessionBean1.lokasi_lrtRowSet}"));

}

private Page page1 = new Page();

public Page getPage1() {
return page1;
}

public void setPage1(Page p) {
this.page1 = p;
}

private Html html1 = new Html();

public Html getHtml1() {
return html1;
}

public void setHtml1(Html h) {
this.html1 = h;
}

private Head head1 = new Head();

public Head getHead1() {
return head1;
}

public void setHead1(Head h) {
this.head1 = h;
}

private Link link1 = new Link();

public Link getLink1() {
return link1;
}

public void setLink1(Link l) {
this.link1 = l;
}

private Body body1 = new Body();

public Body getBody1() {
return body1;
}

public void setBody1(Body b) {
this.body1 = b;
}

private Form form1 = new Form();

public Form getForm1() {
return form1;
}

public void setForm1(Form f) {
this.form1 = f;
}

private ImageComponent image1 = new ImageComponent();

public ImageComponent getImage1() {
return image1;
}

public void setImage1(ImageComponent ic) {
this.image1 = ic;
}

private ImageComponent image2 = new ImageComponent();

public ImageComponent getImage2() {
return image2;
}

public void setImage2(ImageComponent ic) {
this.image2 = ic;
}

private ImageComponent image3 = new ImageComponent();

public ImageComponent getImage3() {
return image3;
}

public void setImage3(ImageComponent ic) {
this.image3 = ic;
}

private Hyperlink id1 = new Hyperlink();

public Hyperlink getId1() {
return id1;
}

public void setId1(Hyperlink h) {
this.id1 = h;
}

private Hyperlink line = new Hyperlink();

public Hyperlink getLine() {
return line;
}

public void setLine(Hyperlink h) {
this.line = h;
}

private Button aboutUs1 = new Button();

public Button getAboutUs1() {
return aboutUs1;
}

public void setAboutUs1(Button b) {
this.aboutUs1 = b;
}

private Button timetable1 = new Button();

public Button getTimetable1() {
return timetable1;
}

public void setTimetable1(Button b) {
this.timetable1 = b;
}

private Button tracker1 = new Button();

public Button getTracker1() {
return tracker1;
}

public void setTracker1(Button b) {
this.tracker1 = b;
}

private Button home1 = new Button();

public Button getHome1() {
return home1;
}

public void setHome1(Button b) {
this.home1 = b;
}

private Button fare1 = new Button();

public Button getFare1() {
return fare1;
}

public void setFare1(Button b) {
this.fare1 = b;
}

private Button admin1 = new Button();

public Button getAdmin1() {
return admin1;
}

public void setAdmin1(Button b) {
this.admin1 = b;
}

private MapComponent mapViewer1 = new MapComponent();

public MapComponent getMapViewer1() {
return mapViewer1;
}

public void setMapViewer1(MapComponent mc) {
this.mapViewer1 = mc;
}

private MapPoint mapViewer1_center = new MapPoint();

public MapPoint getMapViewer1_center() {
return mapViewer1_center;
}

public void setMapViewer1_center(MapPoint mp) {
this.mapViewer1_center = mp;
}

private DropDown dropDown1 = new DropDown();

public DropDown getDropDown1() {
return dropDown1;
}

public void setDropDown1(DropDown dd) {
this.dropDown1 = dd;
}

private SingleSelectOptionsList dropDown1DefaultOptions = new SingleSelectOptionsList();

public SingleSelectOptionsList getDropDown1DefaultOptions() {
return dropDown1DefaultOptions;
}

public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown1DefaultOptions = ssol;
}

private Button getMap = new Button();

public Button getGetMap() {
return getMap;
}

public void setGetMap(Button b) {
this.getMap = b;
}

private MessageGroup messageGroup1 = new MessageGroup();

public MessageGroup getMessageGroup1() {
return messageGroup1;
}

public void setMessageGroup1(MessageGroup mg) {
this.messageGroup1 = mg;
}

private GeoCoder geoCoder1 = new GeoCoder();

public GeoCoder getGeoCoder1() {
return geoCoder1;
}

public void setGeoCoder1(GeoCoder gc) {
this.geoCoder1 = gc;
}


private boolean displayMap = false; //display map ble user enter id lrt.


private MapMarker[] markers;
public MapMarker[] getMarkers(){
return markers;
}

private CachedRowSetDataProvider lokasi_lrtDataProvider = new CachedRowSetDataProvider();

public CachedRowSetDataProvider getLokasi_lrtDataProvider() {
return lokasi_lrtDataProvider;
}

public void setLokasi_lrtDataProvider(CachedRowSetDataProvider crsdp) {
this.lokasi_lrtDataProvider = crsdp;
}

private MapMarker mapMarker1 = new MapMarker();

public MapMarker getMapMarker1() {
return mapMarker1;
}

public void setMapMarker1(MapMarker mm) {
this.mapMarker1 = mm;
}

public idLRT() {
}

public void init() {

super.init();

try {
_init();
} catch (Exception e) {
log("idLRT Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}


}

public void preprocess() {
}


public void prerender() {
if(displayMap){
mapViewer1_center.setLatitude(getRequestBean1().getLatitude(
));
mapViewer1_center.setLongitude(getRequestBean1().getLongitud
e());
getLRT();

Enumeration e = log1.elements();
Enumeration e1 = lat1.elements();
Enumeration e2 = line1.elements();

int i = 0;

markers = new MapMarker[i];

mapMarker1.setLatitude(Double.parseDouble(e1.nextElement().t
oString()));

mapMarker1.setLongitude(Double.parseDouble(e.nextElement().t
oString()));

mapMarker1.setMarkup("This&nbsp;is&nbsp;the&nbsp;"+e2.nextElement()+"&nbsp;!&nbsp;");

}
}


public void destroy() {
lokasi_lrtDataProvider.close();
}


protected SessionBean1 getSessionBean1() {
return (SessionBean1)getBean("SessionBean1");
}


protected RequestBean1 getRequestBean1() {
return (RequestBean1)getBean("RequestBean1");
}


protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1)getBean("ApplicationBean1");
}

public String sri_petaling1_action() {


return "case1";
}

public String home_action() {


return "case5";
}

public void dropDown1_processValueChange(ValueChangeEvent event) {


}

public String getMap_action() {

String LRT = (String)(dropDown1.getSelected());
getCoordinate(LRT);
getRequestBean1().setLatitude(latitude);
getRequestBean1().setLogitude(longitude);
displayMap=true;
return null;
}

private void getCoordinate(String LRT) {
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception E){
System.err.println("Unable to load Driver.");
E.printStackTrace();
}

try{
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/rapidkl","root","root");
java.sql.Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from lokasi_lrt GROUP BY id_lrt ORDER BY masa DESC where id_lrt ='" + LRT + "'");

while(rs.next()){
id = rs.getString(1);
this.longitude = rs.getDouble(5);
this.latitude = rs.getDouble(4);

}

rs.close();
stmt.close();
conn.close();
}
catch(SQLException E){
System.out.println("SQLException: "+E.getMessage());
System.out.println("SQLState: "+E.getSQLState());
System.out.println("VendorError: "+E.getErrorCode());
}
}

private void getLRT() {
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception E){
System.err.println("Unable to load Driver.");
E.printStackTrace();
}

try{
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/rapidkl","root","root");
java.sql.Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from lokasi_lrt ");

line1 = new Vector<Object>();
lat1 = new Vector<Object>();
log1 = new Vector<Object>();

while(rs.next()){
id = rs.getString(1);
this.lines = rs.getString(2);
this.log = rs.getDouble(5);
this.lat = rs.getDouble(4);
line1.add(lines);
log1.add(log);
lat1.add(lat);

}

rs.close();
stmt.close();
conn.close();
}
catch(SQLException E){
System.out.println("SQLException: "+E.getMessage());
System.out.println("SQLState: "+E.getSQLState());
System.out.println("VendorError: "+E.getErrorCode());
}
}

}

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 

RSS Lo-Fi Version Time is now: 4th December 2008 - 04:39 AM

© 1998-2008 Khazanah Maya Computer Systems