導航:首頁 > 編程語言 > 搞的地圖代碼

搞的地圖代碼

發布時間: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

閱讀全文

與搞的地圖代碼相關的資料

熱點內容
系統軟體處理數據有哪些好處 瀏覽:706
flash資料庫動態開發專業教程下載 瀏覽:874
u盤文件被鎖怎麼消除 瀏覽:39
前三季度gdp數據廣東什麼時候公布 瀏覽:726
ug導出stp文件後顯示 瀏覽:262
struts2文件上傳例子 瀏覽:480
智能粉碎文件名 瀏覽:625
編程是干什麼的適合幾歲兒童上 瀏覽:412
photoshop中文版最新版本 瀏覽:828
什麼app能點播廣西衛視 瀏覽:338
word如何批量放入相應的文件夾 瀏覽:884
如何在excel一列刪除數據 瀏覽:534
商科學生為什麼學編程 瀏覽:438
壓縮文件記錄 瀏覽:967
網上招聘找工作去哪個網站 瀏覽:276
ps生成文件怎麼打開 瀏覽:631
文檔過期文件如何找回 瀏覽:968
daf是什麼文件 瀏覽:851
雲閃付可以適用於哪些app 瀏覽:210
jsp循環輸出44的表格 瀏覽:772

友情鏈接