mysql百度地图数据库
string drivername=com.mysql.jdbc.driver;//驱动程序名
string username=root;//数据库用户名
string userpasswd=qwe;//密码
string dbname=test;//数据库名
string tablename=location;//表名
//联结字符串
string url=jdbc:mysql://localhost/+dbname+?user=+username+&password=+userpasswd;
class.forname(com.mysql.jdbc.driver).newinstance();
connection connection=drivermanager.getconnection(url);
statement statement = connection.createstatement();
string sql=select * from +tablename;
resultset rs = statement.executequery(sql);
int size = rs.getrow();//数据行数
resultsetmetadata rmeta = rs.getmetadata();//获得数据结果集合
int numcolumns=rmeta.getcolumncount();//确定数据集的列数,亦字段数
//输出每一个数据值
out.print(size+ );
out.print(
);
while(rs.next()) {
out.print(rs.getstring(1)+ );//编号
out.print(|);
double point1=rs.getdouble(4);
double point2=rs.getdouble(3);
out.print(point1+ );//输出经度
out.print(point2+ );//输出纬度
out.print(
);
}
%>
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}#l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}#r-result{height:100%;width:20%;float:left;}
折线
var map = new bmap.map(allmap);var point = new bmap.point(113.001,28.23540605);var p=document.from1.myhidden.value;map.centerandzoom(point, 13);var polyline = new bmap.polyline([ new bmap.point(113.0051,28.2334), new bmap.point(113.0031,28.2322), new bmap.point(113.0041,28.23241)], {strokecolor:blue, strokeweight:6, strokeopacity:0.5});//这里的坐标需要从数据库获取!! 卡在这里了map.addoverlay(polyline);