地圖兩點軌跡java代碼,如何生成足跡地圖

想用java 做一個平臺,能夠調(diào)用百度或谷歌地圖并在地圖上顯示定位位置和軌跡回放,涉及java 的那些知識

如果是WEB方式,需要:

我們一直強調(diào)做網(wǎng)站、網(wǎng)站建設(shè)對于企業(yè)的重要性,如果您也覺得重要,那么就需要我們慎重對待,選擇一個安全靠譜的網(wǎng)站建設(shè)公司,企業(yè)網(wǎng)站我們建議是要么不做,要么就做好,讓網(wǎng)站能真正成為企業(yè)發(fā)展過程中的有力推手。專業(yè)網(wǎng)站制作公司不一定是大公司,創(chuàng)新互聯(lián)公司作為專業(yè)的網(wǎng)絡(luò)公司選擇我們就是放心。

java開發(fā)移動端APP,獲取GPS數(shù)據(jù)并存入數(shù)據(jù)庫

頁面JSP調(diào)用百度地圖API

地圖上所需的位置坐標從數(shù)據(jù)庫中查詢

涉及到的知識比較廣,JSP\JAVA ANDROID IDE\J2SE\HTML\DATABASE

如題,java從服務器獲取gpx格式的文件解析出其中的坐標點顯示在百度地圖軌跡路線

GPX Viewer 是 一個用來查看 GPX 文件格式的軟件,可以同時顯示多個GPX文件。該軟件可以顯示路點、跟蹤,高亮顯示選中的路線,使用圖表的方式顯示速度和時間、距離、平均速度、最大速度,GPS信息;支持放大縮小、平滑顯示燈

求一個java寫的地圖程序

用java寫一個地圖編輯器

記得媒體在采訪c++之父的時候,他說作為程序員,要相信自己能夠解決已經(jīng)理解的任何事情.

換句話說:您可以解決任何問題,只要想得明白

現(xiàn)實問題:開發(fā)一個基于地磚的二維游戲的地圖編輯器,要求生成兩個binary文件,各包含一個二維數(shù)組,*.map存放地磚,花花草草什么的.*.item放道具,比如某個點可能會觸發(fā)一個事件.很簡單,隨便寫.看到這里您已經(jīng)大致明白程序的整體結(jié)構(gòu).

計算機語言:java.

要理解事件必須分析

初步來看,地圖編輯器:生成某種形式的若干數(shù)組,無論是哪種形式的數(shù)組,你的目的:

生成數(shù)組.地圖是實際是一個(x,y)的二維坐標系,這很容易讓人聯(lián)系到:亦無論

我準備把設(shè)置兩個程序界面(主界面/map界面),java的布局管理器不好擺弄,不如分開兩個class,主界面用jbuilder自動創(chuàng)建的application模塊(帶菜單).map界面自己寫,也是jframe,類之間相互傳遞消息,map界面將在程序開始時被初始化,也可以在程序從主界面中初始化(有問題)

構(gòu)建程序

以下內(nèi)容為程序代碼:

basepanel.setlayout(new gridlayout(5, 5));

for (byte i = 0; i 9; i++) {

basemapbutton[i] = new

((icon) pic.getimageicon(i, 0));

basemapbutton[i].setbuttontitle(i);

basemapbutton[i].addactionlistener(buttonlistener);

basepanel.add(basemapbutton[i]);

}

itempanel.setlayout(new gridlayout(5, 5));

for (byte i = 0; i 3; i++) {

itemmapbutton[i] = new mapbutton((icon) pic.getimageicon(i, 1));

itemmapbutton[i].setbuttontitle(i);

itemmapbutton[i].addactionlistener(buttonlistener1);

itempanel.add(itemmapbutton[i]);

}

tabbedpane.addtab("bases", basepanel);

tabbedpane.addtab("items", itempanel);

contentpane.add(tabbedpane, borderlayout.center);

有兩個地方要解釋:

mapbutton:自己寫的一個類

以下內(nèi)容為程序代碼:

import javax.swing.icon;

import javax.swing.jbutton;

public class mapbutton extends jbutton {

public mapbutton() {

super();

}

public mapbutton(string arg0) {

super(arg0);

}

public mapbutton(action arg0) {

super(arg0);

}

public mapbutton(icon arg0) {

super(arg0);

}

public mapbutton(string arg0, icon arg1) {

super(arg0, arg1);

}

public byte width, height;

//public pic_w, pic_y;

public void setbuttontitle(byte w, byte h) {

width = w;

height = h;

}

public void setbuttontitle(byte w){

width =w;

}

public byte getbuttonwidth() {

return width;

}

public byte getbuttonheight() {

return height;

}

}

pic:自己寫的mappic類的intance:

以下內(nèi)容為程序代碼:

package com.nenghe.mapeditor;

import javax.swing.imageicon;

public class mappic {

imageicon[] baseimages;

imageicon[] itemimages;

imageicon image1;

public mappic() {

init();

}

public void init() {

baseimages = new imageicon[9];

baseimages[0] = new imageicon(mappic.class.getresource("m1.png"/images/wink.gif[/img]);

baseimages[1] = new imageicon(mappic.class.getresource("m2.png"/images/wink.gif[/img]);

baseimages[2] = new imageicon(mappic.class.getresource("m3.png"/images/wink.gif[/img]);

baseimages[3] = new imageicon(mappic.class.getresource("m4.png"/images/wink.gif[/img]);

baseimages[4] = new imageicon(mappic.class.getresource("m5.png"/images/wink.gif[/img]);

baseimages[5] = new imageicon(mappic.class.getresource("m6.png"/images/wink.gif[/img]);

baseimages[6] = new imageicon(mappic.class.getresource("m7.png"/images/wink.gif[/img]);

baseimages[7] = new imageicon(mappic.class.getresource("m8.png"/images/wink.gif[/img]);

baseimages[8] = new imageicon(mappic.class.getresource("m9.png"/images/wink.gif[/img]);

itemimages = new imageicon[3];

itemimages[0] = new imageicon(mappic.class.getresource("error.png"/images/wink.gif[/img]);

itemimages[1] = new imageicon(mappic.class.getresource("i1.png"/images/wink.gif[/img]);

itemimages[2] = new imageicon(mappic.class.getresource("i2.png"/images/wink.gif[/img]);

}

public imageicon getimageicon(int x, int flags) {

if (flags == 0) {

return baseimages[x];

} else if (flags == 1) {

return itemimages[x];

}

return null;

}

}

寫mapbutton在于處理事件的時候可以準確的獲得按鈕的坐標,忘了說了,map界面中我是用按鈕代替地圖方格的.這是很容易想到的,最笨也是最省力的辦法

pic單獨寫好改,什么時候內(nèi)容改變了,很容易改,硬要合寫沒有也隨便.

下面就是事件了

有兩個事件要處理,第一個是按鈕事件,第二個菜單事件

按鈕事件我套用這樣的結(jié)構(gòu)

以下內(nèi)容為程序代碼:

actionlistener buttonlistener = new actionlistener() {

public void actionperformed(actionevent e) {

//system.out.println(e.tostring());

mapbutton pressedbutton = (mapbutton) e.getsource();

mapdraw.temp_x = pressedbutton.getbuttonwidth();

mapdraw.temp_y = 0;

//system.out.println(mapdraw.temp_x+" "+mapdraw.temp_y);

}

};

....

basemapbutton[i].addactionlistener(buttonlistener);

jbuilder中把按鈕事件事件單獨生成一個類,我不明白,看不懂.真的很高深.

菜單事件模型jbuilder自己加的.overwrite

以下內(nèi)容為程序代碼:

public void *_actionperformed(actionevent e) {...}

用兩個中間值從主界面向map界面?zhèn)鬟f按了什么:

這里是map界面中的按鈕的事件處理程序

以下內(nèi)容為程序代碼:

actionlistener buttonlistener = new actionlistener() {

public void actionperformed(actionevent e) {

mapbutton pressedbutton = (mapbutton) e.getsource();

pressedwidth = pressedbutton.getbuttonwidth();

pressedheight = pressedbutton.getbuttonheight();

if (temp_y == 0) {

if (item[pressedwidth][pressedheight] != 0) {

item[pressedwidth][pressedheight] = 0;

jfm.showmessage("這里的道具已被置空!\nthe item has been null!"/images/wink.gif[/img];

}

map[pressedwidth][pressedheight] = temp_x;

pressedbutton.seticon((icon) pic.getimageicon(temp_x,

temp_y));

} else {

if (map[pressedwidth][pressedheight] == 0) {

jfm.showmessage("道具不能放在這!\nnot put item at this point!"/images/wink.gif[/img];

} else {

if (temp_x == 0) {

byte value = map[pressedwidth][pressedheight];

item[pressedwidth][pressedheight] = 0;

pressedbutton.seticon((icon) pic.getimageicon(

value, 0));

} else {

pressedbutton.seticon((icon) pic.getimageicon(

temp_x, temp_y));

item[pressedwidth][pressedheight] = temp_x;

}

}

}

}

};

請問兩個中間值是什么呢?一目了然哦

最后是生成map

以下內(nèi)容為程序代碼:

public void createmap() throws ioexception {

try {

dataoutputstream mapbinaryfile = new dataoutputstream(

new fileoutputstream(mapeditor.filename + "map"/images/wink.gif[/img]);

dataoutputstream itembinaryfile = new dataoutputstream(

new fileoutputstream(mapeditor.filename + "item"/images/wink.gif[/img]);

mapbinaryfile.writebyte(width);

mapbinaryfile.writebyte(height);

for (byte i = 0; i height; i++)

for (byte j = 0; j width; j++) {

//system.out.println(i+" "+j);

byte mapvalue = map[i][j];

byte itemvalue = item[i][j];

if (mapvalue != 0) {

system.out.println(i+" "+j+" "+ mapvalue);

mapbinaryfile.writebyte(j);

mapbinaryfile.writebyte(i);

mapbinaryfile.writebyte(mapvalue);

}

if (itemvalue != 0) {

itembinaryfile.writebyte(j);//x

itembinaryfile.writebyte(i);//y

itembinaryfile.writebyte(itemvalue);

}

}

mapbinaryfile.close();

itembinaryfile.close();

} catch (eofexception e) {

system.err.println("error"/images/wink.gif[/img];

}

}

如何使用java和百度地圖api 得到兩點之間的路程(駕車行駛距離)

獲取到兩點的經(jīng)緯度,再調(diào)用百度地圖的api計算。我記得,有一個計算距離的api.

script?type="text/javascript"

//?百度地圖API功能

var?map?=?new?BMap.Map("allmap");

map.centerAndZoom("重慶",12);??//初始化地圖,設(shè)置城市和地圖級別。

var?pointA?=?new?BMap.Point(106.486654,29.490295);??//?創(chuàng)建點坐標A--大渡口區(qū)

var?pointB?=?new?BMap.Point(106.581515,29.615467);??//?創(chuàng)建點坐標B--江北區(qū)

alert('從大渡口區(qū)到江北區(qū)的距離是:'+(map.getDistance(pointA,pointB)).toFixed(2)+'?米。');??//獲取兩點距離,保留小數(shù)點后兩位

var?polyline?=?new?BMap.Polyline([pointA,pointB],?{strokeColor:"blue",?strokeWeight:6,?strokeOpacity:0.5});??//定義折線

map.addOverlay(polyline);?????//添加折線到地圖上

/script

怎么用java自定義一個隊列,來存在地圖上路線的各個坐標。

java很多類都是隊列形式的,你看看源碼AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue,LinkedList, PriorityBlockingQueue, PriorityQueue, SynchronousQueue,或則看看數(shù)據(jù)結(jié)構(gòu)。

求java實現(xiàn)矩陣圖上任意兩點的最短路徑源碼

我用的是遞歸調(diào)用方法,有個小問題就是在打印步數(shù)的時候是返向的,原因是就是程序不斷的調(diào)用自己,到最后判斷基值位準退出調(diào)用。這才開始從棧里取出方法進行執(zhí)行的原因。

代碼欣賞:

public?static?int?step?=?1;

public?static?StringBuffer?printStep?=?new?StringBuffer();

public?static?int[][]?maze?={{1,1,1,1,1,1,1,1,1,1,1},

{1,0,1,0,1,0,0,0,0,0,1?},

{1,0,1,0,0,0,1,0,1,1,1?},

{1,0,0,0,1,0,1,0,0,0,1?},

{1,0,1,1,0,0,1,0,0,1,1?},//?0代表可以通過,1代表不可通過

{1,0,1,0,1,1,0,1,0,0,1?},

{1,0,0,0,0,0,0,0,1,0,1?},

{1,0,1,0,1,0,1,0,1,0,1?},

{1,0,0,1,0,0,1,0,1,0,1?},

{1,1,1,1,1,1,1,1,1,1,1?}?};

public?static?void?main(String[]?args)?{

int?i,?j;?//循環(huán)記數(shù)變量

Sample.way(1,?1);//二維數(shù)組起始值從下標1,1開始

System.out.println("起點從坐標?x?=?1,?y?=?1開始");

System.out.println("終點坐標是?x?=?8,?y?=?9結(jié)束");

System.out.println("這是迷宮圖表");

System.out.println("??0????1????2????3????4????5????6????7????8????9???10");

System.out.println("??+---+---+---+---+---+---+---+---+---+---+---+---+---+");

for(i?=?0;?i??10;?i++){

System.out.print("?"?+?i?+?"‖");

for(j?=?0;?j??11;?j++)

System.out.print("-"?+?maze[i][j]?+?"-‖");

System.out.println("");

System.out.println("??+---+---+---+---+---+---+---+---+---+---+---+---+---+");

}

//打印顯示步數(shù)

System.out.print(printStep.toString());

}

public?static?boolean?way(int?x,?int?y){

if(maze[8][9]?==?2)//代表遞歸終止條件(也就是當走出出口時標記為?2)

return?true;

else{

if(maze[y][x]?==?0){

maze[y][x]?=?2;

/*

*?下面if判斷條件代表當前坐標為基點,

*?根據(jù)判斷對當前位置進行遞歸調(diào)用:如:

*?往上、往右上、往右、往右下、往下、

*?往左下、往左、往左上的坐標是否可走,

*?判斷是否可走的返回條件是:

*?2代表可通過、1代表不能通過、3表示已經(jīng)走過,但是未能走通。

*/

if(way(x,?y?-?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?+?1,?y?-?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?+?1?,?y)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?+?1,?y?+?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x,?y?+?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?-?1,?y?+?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?-?1,?y)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else?if(way(x?-?1,?y?-?1)){

printStep.append("第?"?+?step?+?"?步的所走的位置是?x?=?"?+?x?+?"?y?=?"?+?y?+?"\n");

step++;

return?true;

}else{

maze[y][x]?=?3;

return?false;

}

}else

return?false;

}

}

復制代碼前需要樓主自己創(chuàng)建個?類

Sample.way(1,?1);這句代碼是我的類的靜態(tài)調(diào)用,改下XXXXX.way(1,?1);

XXXXX代表你創(chuàng)建的類。

下面是這個程序運行后的截圖

標題名稱:地圖兩點軌跡java代碼,如何生成足跡地圖
瀏覽地址:http://muchs.cn/article26/hcjpjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、網(wǎng)站建設(shè)響應式網(wǎng)站、小程序開發(fā)、域名注冊、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設(shè)