‘壹’ android中用高德地图通过地址获取经纬度
1.首先需要申请一个高德地图的key值,只有有了这个才能使用高德地图AP。申请地址,点击“获取KEY”,按步骤填空
2.准备工作做好,写入如下源码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>输入提示后查询,点击获取坐标</title>
<style type="text/css">
body{
margin:0;
height:100%;
width:100%;
position:absolute;
font-size:12px;
}
#mapContainer{
position: absolute;
top:0;
left: 0;
right:0;
bottom:0;
}
#tip{
background-color:#fff;
border:1px solid #ccc;
padding-left:10px;
padding-right:2px;
position:absolute;
min-height:65px;
top:10px;
font-size:12px;
right:10px;
border-radius:3px;
overflow:hidden;
line-height:20px;
min-width:400px;
}
#tip input[type="button"]{
background-color: #0D9BF2;
height:25px;
text-align:center;
line-height:25px;
color:#fff;
font-size:12px;
border-radius:3px;
outline: none;
border:0;
cursor:pointer;
}
#tip input[type="text"]{
height:25px;
border:1px solid #ccc;
padding-left:5px;
border-radius:3px;
outline:none;
}
#pos{
height: 70px;
background-color: #fff;
padding-left: 10px;
padding-right: 10px;
position:absolute;
font-size: 12px;
right: 10px;
bottom: 30px;
border-radius: 3px;
line-height: 30px;
border:1px solid #ccc;
}
#pos input{
border:1px solid #ddd;
height:23px;
border-radius:3px;
outline:none;
}
#result1{
max-height:300px;
}
</style>
</head>
<body>
<div id="mapContainer" ></div>
<div id="tip">
<b>请输入关键字:</b>
<input type="text" id="keyword" name="keyword" value="" onkeydown='keydown(event)' style="width: 95%;"/>
<div id="result1" name="result1"></div>
</div>
<div id="pos">
<b>鼠标左键在地图上单击获取坐标</b>
<br><div>X:<input type="text" id="lngX" name="lngX" value=""/> Y:<input type="text" id="latY" name="latY" value=""/></div>
</div>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=您的Key值"></script>
<script type="text/javascript">
var windowsArr = [];
var marker = [];
var mapObj = new AMap.Map("mapContainer", {
resizeEnable: true,
view: new AMap.View2D({
resizeEnable: true,
zoom:13//地图显示的缩放级别
}),
keyboardEnable:false
});
var clickEventListener=AMap.event.addListener(mapObj,'click',function(e){
document.getElementById("lngX").value=e.lnglat.getLng();
document.getElementById("latY").value=e.lnglat.getLat();
});
document.getElementById("keyword").onkeyup = keydown;
//输入提示
function autoSearch() {
var keywords = document.getElementById("keyword").value;
var auto;
//加载输入提示插件
AMap.service(["AMap.Autocomplete"], function() {
var autoOptions = {
city: "" //城市,默认全国
};
auto = new AMap.Autocomplete(autoOptions);
//查询成功时返回查询结果
if ( keywords.length > 0) {
auto.search(keywords, function(status, result){
autocomplete_CallBack(result);
});
}
else {
document.getElementById("result1").style.display = "none";
}
});
}
//输出输入提示结果的回调函数
function autocomplete_CallBack(data) {
var resultStr = "";
var tipArr = data.tips;
if (tipArr&&tipArr.length>0) {
for (var i = 0; i < tipArr.length; i++) {
resultStr += "<div id='divid" + (i + 1) + "' onmouseover='openMarkerTipById(" + (i + 1)
+ ",this)' onclick='selectResult(" + i + ")' onmouseout='onmouseout_MarkerStyle(" + (i + 1)
+ ",this)' style=\"font-size: 13px;cursor:pointer;padding:5px 5px 5px 5px;\"" + "data=" + tipArr[i].adcode + ">" + tipArr[i].name + "<span style='color:#C1C1C1;'>"+ tipArr[i].district + "</span></div>";
}
}
else {
resultStr = " π__π 亲,人家找不到结果!<br />要不试试:<br />1.请确保所有字词拼写正确<br />2.尝试不同的关键字<br />3.尝试更宽泛的关键字";
}
document.getElementById("result1").curSelect = -1;
document.getElementById("result1").tipArr = tipArr;
document.getElementById("result1").innerHTML = resultStr;
document.getElementById("result1").style.display = "block";
}
//输入提示框鼠标滑过时的样式
function openMarkerTipById(pointid, thiss) { //根据id打开搜索结果点tip
thiss.style.background = '#CAE1FF';
}
//输入提示框鼠标移出时的样式
function onmouseout_MarkerStyle(pointid, thiss) { //鼠标移开后点样式恢复
thiss.style.background = "";
}
//从输入提示框中选择关键字并查询
function selectResult(index) {
if(index<0){
return;
}
if (navigator.userAgent.indexOf("MSIE") > 0) {
document.getElementById("keyword").onpropertychange = null;
document.getElementById("keyword").onfocus = focus_callback;
}
//截取输入提示的关键字部分
var text = document.getElementById("divid" + (index + 1)).innerHTML.replace(/<[^>].*?>.*<\/[^>].*?>/g,"");
var cityCode = document.getElementById("divid" + (index + 1)).getAttribute('data');
document.getElementById("keyword").value = text;
document.getElementById("result1").style.display = "none";
//根据选择的输入提示关键字查询
mapObj.plugin(["AMap.PlaceSearch"], function() {
var msearch = new AMap.PlaceSearch(); //构造地点查询类
AMap.event.addListener(msearch, "complete", placeSearch_CallBack); //查询成功时的回调函数
msearch.setCity(cityCode);
msearch.search(text); //关键字查询查询
});
}
//定位选择输入提示关键字
function focus_callback() {
if (navigator.userAgent.indexOf("MSIE") > 0) {
document.getElementById("keyword").onpropertychange = autoSearch;
}
}
//输出关键字查询结果的回调函数
function placeSearch_CallBack(data) {
//清空地图上的InfoWindow和Marker
windowsArr = [];
marker = [];
mapObj.clearMap();
var resultStr1 = "";
var poiArr = data.poiList.pois;
var resultCount = poiArr.length;
for (var i = 0; i < resultCount; i++) {
resultStr1 += "<div id='divid" + (i + 1) + "' onmouseover='openMarkerTipById1(" + i + ",this)' onmouseout='onmouseout_MarkerStyle(" + (i + 1) + ",this)' style=\"font-size: 12px;cursor:pointer;padding:0px 0 4px 2px; border-bottom:1px solid #C1FFC1;\"><table><tr><td><img src=\"http://webapi.amap.com/images/" + (i + 1) + ".png\"></td>" + "<td><h3><font color=\"#00a6ac\">名称: " + poiArr[i].name + "</font></h3>";
resultStr1 += TipContents(poiArr[i].type, poiArr[i].address, poiArr[i].tel) + "</td></tr></table></div>";
addmarker(i, poiArr[i]);
}
mapObj.setFitView();
}
//鼠标滑过查询结果改变背景样式,根据id打开信息窗体
function openMarkerTipById1(pointid, thiss) {
thiss.style.background = '#CAE1FF';
windowsArr[pointid].open(mapObj, marker[pointid]);
}
//添加查询结果的marker&infowindow
function addmarker(i, d) {
var lngX = d.location.getLng();
var latY = d.location.getLat();
var markerOption = {
map:mapObj,
icon:"http://webapi.amap.com/images/" + (i + 1) + ".png",
position:new AMap.LngLat(lngX, latY)
};
var mar = new AMap.Marker(markerOption);
marker.push(new AMap.LngLat(lngX, latY));
var infoWindow = new AMap.InfoWindow({
content:"<h3><font color=\"#00a6ac\"> " + (i + 1) + ". " + d.name + "</font></h3>" + TipContents(d.type, d.address, d.tel),
size:new AMap.Size(300, 0),
autoMove:true,
offset:new AMap.Pixel(0,-30)
});
windowsArr.push(infoWindow);
var aa = function (e) {infoWindow.open(mapObj, mar.getPosition());};
AMap.event.addListener(mar, "mouseover", aa);
}
//infowindow显示内容
function TipContents(type, address, tel) { //窗体内容
if (type == "" || type == "undefined" || type == null || type == " undefined" || typeof type == "undefined") {
type = "暂无";
}
if (address == "" || address == "undefined" || address == null || address == " undefined" || typeof address == "undefined") {
address = "暂无";
}
if (tel == "" || tel == "undefined" || tel == null || tel == " undefined" || typeof address == "tel") {
tel = "暂无";
}
var str = " 地址:" + address + "<br /> 电话:" + tel + " <br /> 类型:" + type;
return str;
}
function keydown(event){
var key = (event||window.event).keyCode;
var result = document.getElementById("result1")
var cur = result.curSelect;
if(key===40){//down
if(cur + 1 < result.childNodes.length){
if(result.childNodes[cur]){
result.childNodes[cur].style.background='';
}
</script>
</body>
</html>
‘贰’ Android 百度地图 根据地址 查到其经纬度,能有比较简单代码吗
mMKSearch.geocode(key, city);//地址解析
返回结果在都在MKSearchListener里的onGetAddrResult方法中,具体区分是逆地址解析的结果还是地址解析的结果需要判断MKAddrInfo中的type字段,type字段为MKAddrInfo.MK_GEOCODE的是地理编码的结果
if (res.type == MKAddrInfo.MK_GEOCODE) {
//地理编码:通过地址检索坐标点
String strInfo = String.format("纬度:%f 经度:%f", res.geoPt.getLatitudeE6()/1e6, res.geoPt.getLongitudeE6()/1e6);
Toast.makeText(GeoCoderDemo.this, strInfo, Toast.LENGTH_LONG).show();
}
‘叁’ 怎么在android百度地图通过经纬度来定位并且显示出地图位置
1、设置AndroidManfest.xml权限ViewCode2、配置jar包3、初始化设置BMapManagerViewCodemapManager=newBMapManager(this);mapManager.init("",newMyMKGeneralListener());//设置通知间隔:iMaxSecond-最大通知间隔,单位:秒;iMinSecond-最小通知间隔,单位:秒mapManager.getLocationManager().setNotifyInternal(20,5);4、获取手机经纬度,并显示地址信息ViewCodemapManager.getLocationManager().requestLocationUpdates(newMyLocationListener());mapManager.start();在LocationListener中获取经纬度{@(Locationarg0){intjin=(int)(arg0.getLatitude()*1000000);intwei=(int)(arg0.getLongitude()*1000000);tv1.setText("经度:"+jin+",纬度:"+wei);MKSearchsearch=newMKSearch();search.init(mapManager,newMyMKSearchListener());search.reverseGeocode(newGeoPoint(jin,wei));}}在MKSearch接口中进行地址转化
‘肆’ android怎么获取经度纬度
在Android应用程序中,可以使用LocationManager来获取移动设备所在的地理位置信息。看如下实例:新建android应用程序TestLocation。
http://blog.csdn.net/yyywyr/article/details/39063181
‘伍’ 我想找android手机的手机定位系统,不知道有什么软件可以将经纬度查询用上
到google market上下载一个GPS test软件,然后打开GPS,过段时间就会找到你的经纬度。
‘陆’ android怎么获取一次性经纬度
我们用的就是GPS定位,或者网络定位,失败就失败了,我也不能保证一次定位成功。你要是获取别的地点经纬度,那就只有查询了。
就是说你要别的地点经纬度只能自己去查,那个文件是查好的
自己的手机只能获取自己当前经纬度
‘柒’ android百度地图怎么查看指定地点的经纬度
‘捌’ 有什么安卓软件能够查看自己的经纬度的,要精确点的
能够查看自己经纬度的app很多,例如网络地图、谷歌地图、老虎地图、GPS定位等等都可以。
安卓定位软件:一种安装在安卓手机上的用于随时了解手机位置的软件,是指软件可以通过特定的定位技术来获取移动手机或终端用户的位置信息(经纬度坐标),在电子地图上标出被定位对象的位置的技术,原理可参考引用资料。使用方法为:
一、先把软件下载安装。
二、 用另外一部手机向安装软件的手机发送短信指令0#。
三、当要定位的时候用另外一部手机向安装软件的手机发送短信指令8#。
以下是测试结果:在手机安装了安卓手机防盗追踪软件后,发8#命令可以返回手机所在位置的经纬度,例如:
经纬度:30.2858366,120.1442114
打开网络地图
直接输入:30.2858366,120.1442114
点放大镜,就出来位置了。
‘玖’ android百度地图api怎么获取经纬度
在网络地图的右上角,点击“地图API”。
在地图API页面,把鼠标移动到“工具”菜单项,在下拉菜单中选择“坐标拾取工具”。
比如在搜索栏输入“网络大厦”点击搜索,就会在地图上出现相应的标记,点击你要找的某一个,就能看到相应的坐标。
同理,把找到的坐标输入到搜索栏,把后面“坐标反查”给勾上,点击搜索,就会对应的坐标打上标记,同时会有相应地址在最右边。
同时,把鼠标在地图上滑行,就可以看到,鼠标滑到每一个地方,都会对应显示坐标。
‘拾’ 安卓软件 通过地图查经纬度和海拔
亲爱的楼主你好
应用宝有一些地图软件,可以测量精度和纬度,你可以下载
包括地图地理名称和经纬度以及详细的资料等都可以进行查询,非常的方便
而且应用宝是安卓专用的手机软件管理工具
更专业的软件安全性能可以帮助你提高手机的应用能力
希望对你有帮助