mysql 查询二维数组_使用二维数组从MySQL检索数据

我正在研究谷歌地图api v3代码。

我将所有标记保存在MySQL中,我想要检索这些标记并在地图上显示它们。我正在寻找一个代码来做到这一点,但我发现所有的代码都使用XML文件来保存检索到的数据。我的想法不同,我可以从MySQL中检索数据并将其保存在二维数组中。

我不知道这是一个坏主意,会让我的网站变慢吗?

这些部分来自我的代码:

(markersDAO.java)

String searchQuery = "select * from map";

try

{

//connect to DB

currentCon = ConnectionManager.getConnection();

stmt=currentCon.createStatement();

rs = stmt.executeQuery(searchQuery);

int i=0;

// if user does not exist set userExits to false

while (rs.next()){

m[i][0]=rs.getString(1);

m[i][1]=Double.toString(rs.getDouble(2));

m[i][2]=Double.toString(rs.getDouble(3));

i++;

}

}

catch (Exception ex)

{

System.out.println("Datamap failed 2: An Exception has occurred! " + ex);

}

return m;(googlemap.jsp)

String[][] locations= u.dataMap();%>

var map = new google.maps.Map(document.getElementById('map'), {

zoom: 10,

center: new google.maps.LatLng(-33.92, 151.25),

mapTypeId: google.maps.MapTypeId.ROADMAP

});

var marker;

var f=0;

var myOptions= {

disableAutoPan: false

,maxWidth: "auto"

,pixelOffset: new google.maps.Size(0, 0)

,zIndex: null

,infoBoxClearance: new google.maps.Size(1, 1)

,isHidden: false

,pane: "floatPane"

,enableEventPropagation: false

};

marker = new google.maps.Marker({

position: new google.maps.LatLng(, ),

map: map,

});

var infobox = new InfoBox(myOptions);

google.maps.event.addListener(marker, 'mouseover', (function(marker,f) {

return function() {

infobox.setContent('');

infobox.open(map, marker);

}

f++;

})(marker, f));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值