baidu_33680854 2016-01-08 14:29 采纳率: 0%
浏览 2031

百度地图从MySql中获取经纬度

<%@ page contentType="text/html; charset=utf-8" %>

<%@ page language="java" %>

<%@ page import="com.mysql.jdbc.Driver" %>

<%@ page import="java.sql.*" %>

<%
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("
");
}
%>

<!DOCTYPE html>

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


  • 写回答

1条回答

  • devmiao 2016-01-08 15:53
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog