本文介绍了多边形或/和信息窗口中的标记簇编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您单击某个多边形时,您会获得带有这些多边形名称的信息窗口,可以在此信息窗口中放入此多边形内的标记数(与标记簇编号相同)或将此编号(标记簇编号)放在多边形?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><头><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="initial-scale=1.0, user-scalable=no"/><link rel="stylesheet" type="text/css" href="css2.css" media="screen"/><title>StanOnline</title><style type="text/css">HTML,正文,#map_canvas {宽度:100%;高度:100%;边距:0;填充:0;}.infowindow * {字体大小:90%;保证金:0}</风格><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"><script type="text/javascript" src="http://geoxml3.googlecode.com/svn/branches/polys/geoxml3.js"><script type="text/javascript" src="http://geoxml3.googlecode.com/svn/trunk/ProjectedOverlay.js"><脚本语言=JavaScript"><!--显示/隐藏 div dmenu-->功能切换(ID){var state = document.getElementById(id).style.display;如果(状态=='块'){document.getElementById(id).style.display = 'block';} 别的 {document.getElementById(id).style.display = 'none';}}<script type="text/javascript">var gmarkers = [];函数 makeLink() {} ;var bounds = new google.maps.LatLngBounds();var geoXml = null;var geoXmlDoc = null;无功映射 = 空;var myLatLng = null;var myGeoXml3Zoom = true;var sidebarHtml = "";var infowindow = null;var kmlLayer = null;varpreserveViewport = true;var 文件名 = "http://mini.hr/stanonline/mo_bck.kml";var icon = new google.maps.MarkerImage("http://localhost/projekt/7stanonline/img/punkt.gif",新 google.maps.Size(32, 32), 新 google.maps.Point(0, 0),新的 google.maps.Point(16, 32));var currentPopup;函数 addMarker(lat, lng, info) {var pt = new google.maps.LatLng(lat, lng);bounds.extend(pt);var 标记 = 新的 google.maps.Marker({位置: pt,图标:图标,//地图:地图});var popup = new google.maps.InfoWindow({内容:信息,最大宽度:200});google.maps.event.addListener(标记,点击",函数(){如果(当前弹出窗口!= null){currentPopup.close();currentPopup = null;}弹出窗口(地图,标记);currentPopup = 弹出窗口;});google.maps.event.addListener(popup, "closeclick", function() {currentPopup = null;});gmarkers.push(标记);}函数 MapTypeId2UrlValue(maptype) {var urlValue = 'm';开关(地图类型){案例 google.maps.MapTypeId.HYBRID: urlValue='h';休息;案例 google.maps.MapTypeId.SATELLITE: urlValue='k';休息;案例 google.maps.MapTypeId.TERRAIN: urlValue='t';休息;默认:案例 google.maps.MapTypeId.ROADMAP: urlValue='m';休息;}返回网址值;}函数初始化(){myLatLng = 新的 google.maps.LatLng(45.345537,14.439621);//这些设置了地图的初始中心、缩放和地图类型//如果查询字符串中没有指定无功纬度 = 45.345537;无功lng = 14.439621;无功缩放 = 13;var maptype = google.maps.MapTypeId.ROADMAP;//如果 URL 的 eh 端有任何参数,它们将在 location.search 中//看起来像?marker=3"//跳过第一个字符,我们对?"不感兴趣var query = location.search.substring(1);//在每个&"处拆分其余部分给出argname=value"对列表的字符var pair = query.split("&");for (var i=0; i';geoXmlDoc = doc[0];for (var i = 0; i < geoXmlDoc.placemarks.length; i++) {//console.log(doc[0].markers[i].title);var placemark = geoXmlDoc.placemarks[i];如果(地标.多边形){如果(currentBounds.intersects(placemark.polygon.bounds)){makeSidebarPolygonEntry(i);}var kmlStrokeColor = kmlColor(placemark.style.color);var kmlFillColor = kmlColor(placemark.style.fillcolor);var normalStyle = {strokeColor: kmlStrokeColor.color,strokeWeight: placemark.style.width,strokeOpacity: kmlStrokeColor.opacity,填充颜色:kmlFillColor.color,填充不透明度:kmlFillColor.opacity};placemark.polygon.normalStyle = normalStyle;highlightPoly(placemark.polygon, i);}如果(地标.折线){如果(currentBounds.intersects(placemark.polyline.bounds)){makeSidebarPolylineEntry(i);}var kmlStrokeColor = kmlColor(placemark.style.color);var normalStyle = {strokeColor: kmlStrokeColor.color,strokeWeight: placemark.style.width,strokeOpacity: kmlStrokeColor.opacity};placemark.polyline.normalStyle = normalStyle;highlightPoly(placemark.polyline, i);}/* doc[0].markers[i].setVisible(false);*/}sidebarHtml += "</table>";document.getElementById("sidebar").innerHTML = sidebarHtml;};函数 hide_kml(){geoXml.hideDocument();}函数 unhide_kml(){geoXml.showDocument();}函数 reload_kml(){geoXml.hideDocument();删除 geoXml;geoXml = 新的 geoXML3.parser({地图:地图,单信息窗口:真,afterParse: useTheData,保留视口:真});geoXml.parse(文件名);}函数 hide_polys_kml(){for (var i=0;i<geoXmlDoc.gpolylines.length;i++) {geoXmlDoc.gpolylines[i].setMap(null);}}函数 unhide_polys_kml(){for (var i=0;i<geoXmlDoc.gpolylines.length;i++) {geoXmlDoc.gpolylines[i].setMap(map);}}函数 load_kmlLayer() {kmlLayer = 新的 google.maps.KmlLayer(文件名);google.maps.event.addListener(kmlLayer, status_changed", function() {document.getElementById('kmlstatus').innerHTML = "Kml 状态:"+kmlLayer.getStatus();});kmlLayer.setMap(地图);}函数 hide_kmlLayer() {kmlLayer.setMap(null);}函数 show_kmlLayer() {kmlLayer.setMap(地图);}头部><body onload="初始化()"><div id="map_canvas" style="width:100%; height:100%"></div><div id="dmenu"><div id="隐藏"><a href="javascript:;"onclick="toggle('dmenu');"><img src="img/x.png"></a></div><br> ODABERI KVART:<div id="侧边栏">