Google maps 同时显示标记和多边形(javascript api v3)

Google maps 同时显示标记和多边形(javascript api v3),google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我试图展示属于州边界的标记。我正在使用下面提供的代码(这对标记非常有用),但是当我为状态边界多边形添加多边形坐标数组时,我很难让它工作。任何关于如何为单个多边形添加坐标数组的帮助都将不胜感激。多谢各位 <html> <head> <title>Web Map of Offices</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

我试图展示属于州边界的标记。我正在使用下面提供的代码(这对标记非常有用),但是当我为状态边界多边形添加多边形坐标数组时,我很难让它工作。任何关于如何为单个多边形添加坐标数组的帮助都将不胜感激。多谢各位

<html> 
<head> 
<title>Web Map of Offices</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<style type="text/css"> 
html { height: 100% } 
body { height: 100%; margin: 0px; padding: 0px } 
#map_canvas { height: 100% } 
</style> 

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> 
</script> `enter code here`

<script type="text/javascript">

function initialize() { 
    var myLatlng = new google.maps.LatLng(38.895308,-80.304565);  
    var myOptions = {
    zoom: 8,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
}

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions) ;

    lats = new Array (38.3213861,38.4579809,38.8014155,38.9875643,38.8022869,39.2844968,39.4850848,39.6078332,39.0194418,38.9399985,40.065598,39.2648469,40.4019707,39.5641071,37.7924745,37.3602823,37.8212103,38.304694,38.401603,37.848631,37.5848663,39.4964831,39.401424,39.3356127,37.4360439,38.0121122,39.0713631);
    longs = new Array (-81.5816714,-81.931094,-81.3513514,-81.9755644,-81.7392611,-80.2709958,-80.1425781,-79.9180457,-80.4194388,-79.8539348,-80.722355,-81.5595981,-80.5868196,-80.9960285,-81.1929363,-81.0978385,-80.4235672,-80.830412,-82.492229,-81.993392,-81.3812904,-77.9541342,-79.0133107,-78.7457004,-81.6041864,-81.1274056,-78.9388241);
    hovertitle = new Array ("Charleston WVDRS","Teays Valley WVDRS","Spencer WVDRS","Point Pleasant WVDRS","Ripley WVDRS","Clarksburg WVDRS","Fairmont WVDRS","Morgantown WVDRS","Weston WVDRS","Elkins WVDRS","Wheeling WVDRS","Parkersburg WVDRS","Weirton WVDRS","Sistersville WVDRS","Beckley WVDRS","Princeton WVDRS","Lewisburg WVDRS","Summersville WVDRS","Huntington WVDRS","Logan WVDRS","Mullens WVDRS","Martinsburg WVDRS","Keyser WVDRS","Romney WVDRS","Welch WVDRS","Oak Hill WVDRS","Moorefield WVDRS");
    htmlAll = new Array ("<h5>Charleston WVDRS</h5><img src=offices/Charleston.png width=200 height=150><p>4701 MacCorkle Avenue SE<br>Charleston, WV 25304<br>304-356-<br>304-926-(Fax)</p><p><a href=directions/Charleston.html>Get Directions</a></p>", 
                        "<h5>Teays Valley WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150 alt=NeedPictureOfOffice><p>115 Liberty Square<br>Hurricane, WV 25526<br>304-760-(Phone)<br>304-759-(Fax)</p><p><a href=directions/TeaysValley.html>Get Directions</a></p>",
                        "<h5>Spencer WVDRS</h5><img src=offices/Spencer.png width=200 height=150><p>321 Market Street<br>Spencer, WV 25276<br>304-927-(Phone)<br>304-927-(Fax)</p><p><a href=directions/Spencer.html>Get Directions</a></p>",
                        "<h5>Point Pleasant WVDRS</h5><img src=offices/PointPleasant.png width=200 height=150><p>209 5th Street<br>Point Pleasant, WV 25550<br>304-675-(Phone)<br>304-675-(Fax)</p><p><a href=directions/PointPleasant.html>Get Directions</a>",
                        "<h5>Ripley WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>206 Stone Drive<br>Ripley, WV 25271<br>304-373-(Phone)<br>304-373-(Fax)</p><p><a href=directions/Ripley.html>Get Directions</a>",
                        "<h5>Clarksburg WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>107 Cambridge Place<br>Bridgeport, WV 26330<br>304-842-(Phone)<br>304-842-(Fax)</p><p><a href=directions/Clarksburg.html>Get Directions</a>",
                        "<h5>Fairmont WVDRS</h5><img src=offices/Fairmont.png width=200 height=150><p>Veterans Square<br>320 Adams Street, Suite 106<br>Fairmont, WV 26554<br>304-367-(Phone)<br>304-367-(Fax)</p><p><a href=directions/Fairmont.html>Get Directions</a>",
                        "<h5>Morgantown WVDRS</h5><img src=offices/Morgantown.png width=200 height =150><p>1415 Earl Core Road<br>Morgantown, WV 26505<br>304-285-(Phone)<br>304-285-(Fax)</p><p><a href=directions/Morgantown.html>Get Directions</a>",
                        "<h5>Weston WVDRS</h5><img src=offices/webmapDefault.png width=200 height =150><p>306 Market Place Mall<br>Weston, WV 26451<br>304-269-0547(Phone)<br>304-269-0427(Fax)</p><p><a href=directions/Weston.html>Get Directions</a>",
                        "<h5>Elkins WVDRS</h5><img src=offices/webmapDefault.png width=200 height =150><p>1025 North Randolph Avenue<br>Elkins, WV 26241<br>304-637-0205(Phone)<br>304-637-0209(Fax)</p><p><a href=directions/Elkins.html>Get Directions</a>",
                        "<h5>Wheeling WVDRS</h5><img src=offices/Wheeling.png width=200 height=150><p>Central Union Building<br>40 14th Street, Suite 103<br>Wheeling, WV 26003<br>304-238-1093(Phone)<br>304-238-1096(Fax)</p><p><a href=directions/Wheeling.html>Get Directions</a>",
                        "<h5>Parkersburg WVDRS</h5><img src=offices/Parkersburg.png width=200 height=150><p>State Office Building<br>400 5th Street<br>Parkersburg, WV 26101<br>304-420-4580(Phone)<br>304-420-4583(Fax)</p><p><a href=directions/Parkersburg.html>Get Directions</a>",
                        "<h5>Weirton WVDRS</h5><img src=offices/Weirton.png width=200 height=150><p>100 Municipal Plaza, Suite 200<br>Weirton, WV 26062<br>304-723-5311(Phone)<br>304-723-5318(Fax)</p><p><a href=directions/Weirton.html>Get Directions</a>",
                        "<h5>Sistersville WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>714 Wells Street<br>Sistersville, WV 26175<br>304-652-2354(Phone)<br>304-652-2359(Fax)</p><p><a href=directions/Sistersville.html>Get Directions</a>",
                        "<h5>Beckley WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>800 New River Town Center<br>Beckley, WV 25801<br>304-256-6900(Phone)<br>304-256-6903(Fax)</p><p><a href=directions/Beckley.html>Get Directions</a>",
                        "<h5>Princeton WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>195 Davis Street<br>Princeton, WV 24739<br>304-425-1256(Phone)<br>304-487-2631(Fax)</p><p><a href=directions/Princeton.html>Get Directions</a>",
                        "<h5>Lewisburg WVDRS</h5><img src=offices/Lewisburg.png width=200 height=150><p>777 North Jefferson Street, Suite 105<br>Lewisburg, WV 24901<br>304-647-7515(Phone)<br>304-647-7518(Fax)</p><p><a href=directions/Lewisburg.html>Get Directions</a>",
                        "<h5>Summersville WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>830 Northside Drive, Suite 113<br>Summersville, WV 26651<br>304-872-0813(Phone)<br>304-872-0518(Fax)</p><p><a href=directions/Summersville.html>Get Directions</a>",
                        "<h5>Huntington WVDRS</h5><img src=offices/Huntington.png width=200 height=150><p>2699 Park Avenue, Suite 200<br>Huntington, WV 25704<br>304-528-5585(Phone)<br>304-528-5591(Fax)</p><p><a href=directions/Huntington.html>Get Directions</a>",
                        "<h5>Logan WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>216 Dingess Street<br>Logan, WV 25601<br>304-792-7060(Phone)<br>304-792-7062(Fax)</p><p><a href=directions/Logan.html>Get Directions</a>",
                        "<h5>Mullens WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>316 Howard Avenue<br>Mullens,WV 25882<br>304-294-5653(Phone)<br>304-294-5655(Fax)</p><p><a href=directions/Mullens.html>Get Directions</a>",
                        "<h5>Martinsburg WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>489 Mid Atlantic Parkway, Suite 2<br>Martinsburg, WV 25404<br>304-267-0005(Phone)<br>304-267-0007(Fax)</p><p><a href=directions/Martinsburg.html>Get Directions</a>",
                        "<h5>Keyser WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>67 North Tornado Way<br>Keyser, WV 26726<br>304-788-2313(Phone)<br>304-788-6389(Fax)</p><p><a href=directions/Keyser.html>Get Directions</a>",
                        "<h5>Romney WVDRS</h5><img src=offices/Romney.png width=200 height=150><p>24948 Northwestern Pike<br>Romney, WV 26757<br>304-822-3957<br>304-822-7417</p><p><a href=directions/Romney.html>Get Directions</a>",
                        "<h5>Welch WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>110 Park Avenue<br>Welch, WV 24801<br>304-436-3175(Phone)<br>304-436-3176(Fax)</p><p><a href=directions/Welch.html>Get Directions</a>",
                        "<h5>Oak Hill WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150><p>549 Mall Road<br>Oak Hill, WV 25901<br>304-465-3025(Phone)<br>304-465-3069(Fax)</p><p><a href=directions/OakHill.html>Get Directions</a>",
                        "<h5>Moorefield WVDRS</h5><img src=offices/webmapDefault.png width=200 height=150 alt=NeedPictureOfOffice><p>151 Robert C. Byrd<br>Industrial Park Road, Suite 3<br>Moorefield, WV 26836<br>304-538-2701(Phone)<br>304-538-2718(Fax)</p><p><a href=directions/Moorefield.html>Get Directions</a>");


    markers = new Array ();
    for (var i = 0; i < 30; i++) {
    myLatlng = new google.maps.LatLng(lats[i],longs[i]);

    var contentString = htmlAll[i];
    var infowindow = new google.maps.InfoWindow({
    content: contentString
    });

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
    html: htmlAll[i],
        title: hovertitle[i]
});

google.maps.event.addListener(marker, 'click', function() { 
  infowindow.setContent(this.html);
  infowindow.open(map,this);

});
}}

</script> 
</head> 

<body onLoad="initialize()"> 
<div id="map_canvas"></div> 
</body>
</noscript>
<div style="text-align: center;"><div style="position:relative; top:0; margin-right:auto;margin-    left:auto; z-index:99999">

</div></div> 
</html>

办公室网络地图
html{高度:100%}
正文{高度:100%;边距:0px;填充:0px}
#地图画布{高度:100%}
`在这里输入代码`
函数初始化(){
var mylatng=new google.maps.LatLng(38.895308,-80.304565);
变量myOptions={
缩放:8,
中心:myLatlng,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions);
lats=新阵列(38.3213861,38.4579809,38.8014155,38.9875643,38.8022869,39.2844968,39.4850848,39.6078332,39.0194418,38.9399985,40.065598,39.2648469,40.4019707,39.5641071,37.7924745,37.3602823,37.8212103,38.304694,38.401603,37.48663,39.4964831,39.43431123,39.417,37.417,37.821213);
longs=新阵列(-81.5816714,-81.931094,-81.3513514,-81.9755644,-81.7392611,-80.2709958,-80.1425781,-79.9180457,-80.4194388,-79.8539348,-80.722355,-81.5595981,-80.5868196,-80.9960285,-81.1929363,-81.0978385,-80.4235672,-80.830412,-82.492229,-80.993392,-77.95412,-80.01378,-12974747478,-418,-41804,-418.1276,-418,-120.794,-418,-418,-418,-824,-828,-41794,-418.89;
hovertitle=新阵列(“查尔斯顿WVDRS”、“提斯谷WVDRS”、“斯宾塞WVDRS”、“波因特普莱森特WVDRS”、“里普利WVDRS”、“克拉克斯堡WVDRS”、“费尔蒙特WVDRS”、“摩根敦WVDRS”、“威斯顿WVDRS”、“埃尔金斯WVDRS”、“惠灵WVDRS”、“帕克斯堡WVDRS”、“维顿WVDRS”、“西斯特斯维尔WVDRS”、“贝克利WVDRS”、“普林斯顿WVDRS”、“路易斯堡WVDRS”、“萨默斯维尔WVDRS”“亨廷顿WVDRS”、“洛根WVDRS”、“马伦WVDRS”、“马丁斯堡WVDRS”、“凯瑟WVDRS”、“罗姆尼WVDRS”、“韦尔奇WVDRS”、“橡树山WVDRS”、“摩尔菲尔德WVDRS”);
htmlAll=新阵列(“查尔斯顿WVDRS4701麦考克大道东南
查尔斯顿,WV 25304
304-356-
304-926-(传真)

”, “提斯谷WVDRS115自由广场
飓风,WV 25526
304-760-(电话)
304-759-(传真)

”, “斯宾塞WVDRS321号市场街
斯宾塞,WV 25276
304-927-(电话)
304-927-(传真)

”, “波因特普莱森特WVDRS第五街209号波因特普莱森特,WV 25550
304-675-(电话)
304-675-(传真)

”, “里普利WVDRS206石路
里普利,WV 25271
304-373-(电话)
304-373-(传真)

”, “克拉克斯堡WVDRS107剑桥广场
WV 26330布里奇波特
304-842-(电话)
304-842-(传真)

”, “费尔蒙特退伍军人广场,威斯康辛州费尔蒙特市亚当斯街320号106室,邮编26554,304-367-(电话)
304-367-(传真)

”, “威斯康辛州摩根敦市伯爵核心路1415号,威斯康辛州摩根敦市26505号,304-285-(电话)
304-285-(传真)

”, “威斯顿WVDRS306街市购物中心
威斯顿,WV 26451
304-269-0547(电话)
304-269-0427(传真)

”, “埃尔金斯WVDRS1025北伦道夫大道
威尔金斯,WV 26241
304-637-0205(电话)
304-637-0209(传真)

”, “惠灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威灵威, “威斯康辛州帕克斯堡州办公大楼第五街400号,邮编:26101
304-420-4580(电话)
304-420-4583(传真)

”, “威尔顿威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯敏斯特威斯, “西斯特斯维尔WVDRS714威尔斯街
西斯特斯维尔,WV 26175
304-652-2354(电话)
304-652-2359(传真)

”, “贝克利WVDRS800新河镇中心
WV 25801贝克利
304-256-6900(电话)
304-256-6903(传真)

”, “普林斯顿威斯康星州戴维斯街195号普林斯顿威斯康星州24739号电话304-425-1256传真304-487-2631”, “路易斯堡WVDRS北杰斐逊街777号,威斯康星州路易斯堡105室,邮编:24901
304-647-7515(电话)
304-647-7518(传真)

”, “西弗吉尼亚州萨默斯维尔WVDRS北侧大道830号,西弗吉尼亚州萨默斯维尔套房,邮编:26651
304-872-0813(电话)
304-872-0518(传真)

”, “亨廷顿WVDRS2699公园大道200号套房,WV 25704亨廷顿
304-528-5585(电话)
304-528-5591(传真)

, “洛根WVDRS216丁吉斯街
洛根,WV 25601
304-792-7060(电话)
304-792-7062(传真)

”, “马伦WVDRS316霍华德大道
马伦,WV 25882
304-294-5653(电话)
304-294-5655(传真)

”, “马丁斯堡WVDRS489大西洋中部公园路2号套房,WV 25404
304-267-0005(电话)
304-267-0007(传真)

”, “凯瑟WVDRS67北龙卷风路
凯瑟,WV 26726
304-788-2313(电话)
304-788-6389(传真)

”, “罗姆尼WVDRS24948西北派克
罗姆尼,WV 26757
304-822-3957
304-822-7417

”, “韦尔奇WVDRS110公园大道
韦尔奇,WV 24801
304-436-3175(电话)
304-436-3176(传真)

”, “橡树山WVDRS549 Mall Road
橡树山,WV 25901
304-465-3025(电话)
304-465-3069(传真)

”, “Moorefield WVDRS151罗伯特·C·伯德
WV 26836摩尔菲尔德工业园路3号套房
304-538-2701(电话)
304-538-2718(传真)

”; markers=新数组(); 对于(变量i=0;i<30;i++){ myLatlng=new google.maps.LatLng(lats[i],longs[i]); 变量
    var layer = new google.maps.FusionTablesLayer({
        query: {
            select: 'geometry',
            from: '18_J2uuiZRLon48Lc6bclZ0ckHanbKZB9qg319KV3',
            where: "STATE_NAME CONTAINS IGNORING CASE 'West Virginia'"
        },
        options: {
            styleId: 2,
            templateId: 2
        }
    });
    layer.setMap(map);