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

搞的地圖代碼

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

閱讀全文

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

熱點內容
ps文件界面設置 瀏覽:779
c語言12位的數據應該怎麼存儲 瀏覽:953
將ape導入iphone 瀏覽:107
js組合快捷鍵 瀏覽:174
linux系統盤默認掛在的文件夾 瀏覽:667
淘寶數據包如何操作上架 瀏覽:567
vb編程中輸入cls是什麼意思 瀏覽:81
linuxtime服務 瀏覽:184
瘋狂安卓講義第二版代碼 瀏覽:420
老炮兒三小時版本下載 瀏覽:313
matlab怎麼調試程序 瀏覽:2
winxp升級win7的危害 瀏覽:496
網路沒連上卻不可用是怎麼回事 瀏覽:752
社區版本 瀏覽:738
怎麼查微信公眾號什麼時候開通的 瀏覽:717
安裝三菱編程閃退怎麼回事 瀏覽:488
手機怎麼創建word文件格式 瀏覽:694
c語言連接資料庫 瀏覽:887
數據線粉色和白色哪個是正 瀏覽:775
vb編程應注意什麼 瀏覽:855

友情鏈接