导航:首页 > 编程语言 > 搞的地图代码

搞的地图代码

发布时间:2024-05-16 17:23:00

① 楂樺垎鎮璧 鍥涜屼唬鐮佺殑璇︾粏瑙i噴銆佸囨敞 鍏充簬楂樺痉鍦板浘鐨勫浘鏍囨樉绀

  1. PoiOverlay(Drawablepic, java.util.List<PoiItem>items)

    鏍规嵁缁欏畾鐨勫弬鏁版潵鏋勯犱竴涓狿oiOverlay鐨勬柊瀵硅薄銆傞氳繃姝ゆ瀯閫犲嚱鏁板垱寤篜oi鍥惧眰銆

  2. removeFromMap()
    灏哖oiOverlay浠庡湴鍥句腑绉婚櫎銆傚幓鎺塒oiOverlay涓婃墍鏈夌殑Marker銆

  3. addToMap(MapViewmv)
    灏哖oiOverlay鍔犲叆鍒板湴鍥句腑銆傛坊鍔燤arker鍒板湴鍥句腑銆

  4. zoomToSpan()

    绉诲姩闀滃ご鍒板綋鍓嶇殑瑙嗚掋

② 调用高德地图API实现关键字查询的jsp代码怎么写

API实现关键字查询的jsp
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>关键字查询</title>
<link rel="stylesheet" type="text/css" href="/Public/css/demo.Default.css" />
<script language="javascript" src="http://webapi.amap.com/maps?v=1.2&key="></script>
<script language="javascript">
var mapObj;
var marker = new Array();
var windowsArr = new Array();
//基本地图加载
function mapInit() {
mapObj = new AMap.Map("iCenter");
}
function placeSearch() {
var MSearch;
mapObj.plugin(["AMap.PlaceSearch"], function() {
MSearch = new AMap.PlaceSearch({ //构造地点查询类
city:"021" //城市
});
AMap.event.addListener(MSearch, "complete", keywordSearch_CallBack);//返回地点查询结果
MSearch.search("东方明珠"); //关键字查询
});
}
//添加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, "click", aa);
}
//回调函数
function keywordSearch_CallBack(data) {
var resultStr = "";
var poiArr = data.poiList.pois;
var resultCount = poiArr.length;
for (var i = 0; i < resultCount; i++) {
resultStr += "<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>";
resultStr += TipContents(poiArr[i].type, poiArr[i].address, poiArr[i].tel) + "</td></tr></table></div>";
addmarker(i, poiArr[i]);
}
mapObj.setFitView();
document.getElementById("result").innerHTML = resultStr;
}
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 openMarkerTipById1(pointid, thiss) { //根据id 打开搜索结果点tip
thiss.style.background = '#CAE1FF';
windowsArr[pointid].open(mapObj, marker[pointid]);
}
function onmouseout_MarkerStyle(pointid, thiss) { //鼠标移开后点样式恢复
thiss.style.background = "";
}
</script>
</head>
<body onload="mapInit();">
<div id="iCenter"></div>
<div class="demo_box">
<p><input type="button" value="查询" onclick="placeSearch()"/><br />
</p>
<div id="r_title"><b>关键字查询结果:</b></div>
<div id="result"> </div>
</div>
</body>
</html>
更多0

阅读全文

与搞的地图代码相关的资料

热点内容
苹果手机网络热点老是断网怎么办 浏览:142
文件封装exe 浏览:620
百度地图更新数据库 浏览:767
ap文件让odin程序未响应 浏览:498
网络金融服务方面做了哪些 浏览:839
快速英语文件翻译哪里好 浏览:599
为什么点读笔网络不成功 浏览:709
iphone5s处理器四 浏览:689
手机文件转化为pdf格式 浏览:82
javaclasspath获取 浏览:403
打油菜籽的工具图片 浏览:81
u盘的空文件夹 浏览:931
卖文化产品的APP有哪些 浏览:291
win10备份不好用 浏览:978
三星电视刷机教程 浏览:753
魅族网络4G 浏览:567
网络丢包率标准 浏览:542
word图片嵌入删除 浏览:607
新显卡装不了驱动程序 浏览:587
哪个咨询医生app好用 浏览:653

友情链接