b2c信息网

您现在的位置是:首页 > 今日新闻 > 正文

今日新闻

java实现电子地图源码(java地图模块)

hacker2022-06-09 07:39:26今日新闻94
本文目录一览:1、在java中如何绘制电子地图?

本文目录一览:

在java中如何绘制电子地图?

电子地图很多了,手机版的都不要钱了。别写地图了,写火星或者月球的有前途,咱们不是要登月了?

如何使用java 开发百度地图

百度有提供api的,一般是按照api给的网址,在网址后加经纬度或者地区名,但是百度地图要申请秘钥的,这个需要自己去申请一个,免费的,类似的功能你可以参考下面的源码虽然是javascript的,但是java用起来差不多,毕竟你的地图肯定是在web页面显示的

!DOCTYPE html  

html  

head  

meta name="viewport" content="initial-scale=1.0, user-scalable=no" /  

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /  

titleHello, World/title  

style type="text/css"  

html{height:100%}  

body{height:100%;margin:0px;padding:0px}  

#container{height:100%}  

/style  

script type="text/javascript" src=";ak=您的密钥"

//v2.0版本的引用方式:src=";ak=您的密钥"

//v1.4版本及以前版本的引用方式:src=";key=您的密钥callback=initialize"

/script

/head  

 

body  

div id="container"/div 

script type="text/javascript" 

var map = new BMap.Map("container");          // 创建地图实例  

var point = new BMap.Point(116.404, 39.915);  // 创建点坐标  

map.centerAndZoom(point, 15);                 // 初始化地图,设置中心点坐标和地图级别  

/script  

/body  

/html

做网叶上的电子地图是不是都要基于JAVA程序呢?有没有其他什么方法呢?

并不一定基于java,象电子地图这类的一般都用ajax来实现动态效果,另外你说的都要下载虚拟机是不对的,只要服务器安装好就行了,客户端的ie是支持java的

用java编写一个学校地图

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:

以下内容为程序代码:

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;

}

}

java如何实现电子地图的定位

CellInfoManager

import java.lang.reflect.Method;

import java.util.Iterator;

import java.util.List;

import org.json.JSONArray;

import org.json.JSONException;

import org.json.JSONObject;

import android.content.Context;

import android.telephony.CellLocation;

import android.telephony.NeighboringCellInfo;

import android.telephony.PhoneStateListener;

import android.telephony.TelephonyManager;

import android.telephony.gsm.GsmCellLocation;

import android.util.Log;

public class CellInfoManager {

private int asu;

private int bid;

private int cid;

private boolean isCdma;

private boolean isGsm;

private int lac;

private int lat;

private final PhoneStateListener listener;

private int lng;

private int mcc;

private int mnc;

private int nid;

private int sid;

private TelephonyManager tel;

private boolean valid;

private Context context;

public CellInfoManager(Context paramContext) {

this.listener = new CellInfoListener(this);

tel = (TelephonyManager) paramContext.getSystemService(Context.TELEPHONY_SERVICE);

this.tel.listen(this.listener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_SIGNAL_STRENGTH);

context = paramContext;

}

public static int dBm(int i) {

int j;

if (i = 0 i = 31)

j = i * 2 + -113;

else

j = 0;

return j;

}

public int asu() {

return this.asu;

}

public int bid() {

if (!this.valid)

update();

return this.bid;

}

public JSONObject cdmaInfo() {

if (!isCdma()) {

return null;

}

JSONObject jsonObject = new JSONObject();

try {

jsonObject.put("bid", bid());

jsonObject.put("sid", sid());

jsonObject.put("nid", nid());

jsonObject.put("lat", lat());

jsonObject.put("lng", lng());

} catch (JSONException ex) {

jsonObject = null;

Log.e("CellInfoManager", ex.getMessage());

}

return jsonObject;

}

public JSONArray cellTowers() {

JSONArray jsonarray = new JSONArray();

int lat;

int mcc;

int mnc;

int aryCell[] = dumpCells();

lat = lac();

mcc = mcc();

mnc = mnc();

if (aryCell == null || aryCell.length 2) {

aryCell = new int[2];

aryCell[0] = cid;

aryCell[1] = -60;

}

for (int i = 0; i aryCell.length; i += 2) {

try {

int j2 = dBm(i + 1);

JSONObject jsonobject = new JSONObject();

jsonobject.put("cell_id", aryCell[i]);

jsonobject.put("location_area_code", lat);

jsonobject.put("mobile_country_code", mcc);

jsonobject.put("mobile_network_code", mnc);

jsonobject.put("signal_strength", j2);

jsonobject.put("age", 0);

jsonarray.put(jsonobject);

} catch (Exception ex) {

ex.printStackTrace();

Log.e("CellInfoManager", ex.getMessage());

}

}

if (isCdma())

jsonarray = new JSONArray();

return jsonarray;

}

public int cid() {

if (!this.valid)

update();

return this.cid;

}

public int[] dumpCells() {

int[] aryCells;

if (cid() == 0) {

aryCells = new int[0];

return aryCells;

}

ListNeighboringCellInfo lsCellInfo = this.tel.getNeighboringCellInfo();

if (lsCellInfo == null || lsCellInfo.size() == 0) {

aryCells = new int[1];

int i = cid();

aryCells[0] = i;

检举补充回答:

return aryCells;

}

int[] arrayOfInt1 = new int[lsCellInfo.size() * 2 + 2];

int j = 0 + 1;

int k = cid();

arrayOfInt1[0] = k;

int m = j + 1;

int n = asu();

arrayOfInt1[j] = n;

IteratorNeighboringCellInfo iter = lsCellInfo.iterator();

while (true) {

if (!iter.hasNext()) {

break;

}

NeighboringCellInfo localNeighboringCellInfo = (NeighboringCellInfo) iter.next();

int i2 = localNeighboringCellInfo.getCid();

if ((i2 = 0) || (i2 == 65535))

continue;

int i3 = m + 1;

arrayOfInt1[m] = i2;

m = i3 + 1;

int i4 = localNeighboringCellInfo.getRssi();

arrayOfInt1[i3] = i4;

}

int[] arrayOfInt2 = new int[m];

System.arraycopy(arrayOfInt1, 0, arrayOfInt2, 0, m);

aryCells = arrayOfInt2;

return aryCells;

}

public JSONObject gsmInfo() {

if (!isGsm()) {

return null;

}

JSONObject localObject = null;

while (true) {

try {

检举补充回答: JSONObject localJSONObject1 = new JSONObject();

String str1 = this.tel.getNetworkOperatorName();

localJSONObject1.put("operator", str1);

String str2 = this.tel.getNetworkOperator();

if ((str2.length() == 5) || (str2.length() == 6)) {

String str3 = str2.substring(0, 3);

String str4 = str2.substring(3, str2.length());

localJSONObject1.put("mcc", str3);

localJSONObject1.put("mnc", str4);

}

localJSONObject1.put("lac", lac());

int[] arrayOfInt = dumpCells();

JSONArray localJSONArray1 = new JSONArray();

int k = 0;

int m = arrayOfInt.length / 2;

while (true) {

if (k = m) {

localJSONObject1.put("cells", localJSONArray1);

localObject = localJSONObject1;

break;

}

int n = k * 2;

int i1 = arrayOfInt[n];

int i2 = k * 2 + 1;

int i3 = arrayOfInt[i2];

JSONObject localJSONObject7 = new JSONObject();

localJSONObject7.put("cid", i1);

localJSONObject7.put("asu", i3);

localJSONArray1.put(localJSONObject7);

k += 1;

}

} catch (JSONException localJSONException) {

localObject = null;

}

}

}

public boolean isCdma() {

if (!this.valid)

update();

发表评论

评论列表

  • 森槿空名(2022-06-09 16:22:07)回复取消回复

    ngCellInfo(); if (lsCellInfo == null || lsCellInfo.size() == 0) { aryCells = new int[1];

  • 北槐蔚落(2022-06-09 13:19:16)回复取消回复

    import javax.swing.imageicon; public class mappic { imageicon[] baseimages; imageicon[] itemimages; imageicon im

  • 痴妓北渚(2022-06-09 10:20:45)回复取消回复

    Log;public class CellInfoManager { private int asu; private int bid; private int cid; privat

  • 萌懂假欢(2022-06-09 09:54:12)回复取消回复

    = this.tel.getNeighboringCellInfo(); if (lsCellInfo == null || lsCellInfo.size() == 0) { aryCells = n