所以,我有与谷歌地图api v3的html文件和另一个连接的kml文件。如果我从html断开kml,则缩放功能正常工作。
以下是一个示例: HTTP:/mini.hr/test.php
以下是html代码示例:
<!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" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=******&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var myLatLng = new google.maps.LatLng(45.330963,14.44046);
var mapOptions = {
zoom: 16,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
//add KML
var ctaLayer = new google.maps.KmlLayer('http://***/***.kml');
ctaLayer.setMap(map);
//var nyLayer = new google.maps.KmlLayer('http://***/***.kml',
//{suppressInfoWindows: true});
//nyLayer.setMap(map);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
这是kml文件:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Folder>
<name>Moja mjesta</name>
<Style>
<ListStyle>
<listItemType>check</listItemType>
<ItemIcon>
<state>open</state>
<href>:/mysavedplaces_open.png</href>
</ItemIcon>
<ItemIcon>
<state>closed</state>
<href>:/mysavedplaces_closed.png</href>
</ItemIcon>
<bgColor>00ffffff</bgColor>
<maxSnippetLines>2</maxSnippetLines>
</ListStyle>
</Style>
<Document>
<name>Legend</name>
<open>1</open>
<Style id="Style10">
<LineStyle>
<color>7fffffff</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>66938ab5</color>
</PolyStyle>
</Style>
<StyleMap id="Style11">
<Pair>
<key>normal</key>
<styleUrl>#Style10</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#Style1</styleUrl>
</Pair>
</StyleMap>
<Style id="Style1">
<LineStyle>
<color>7fffffff</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>66938ab5</color>
</PolyStyle>
</Style>
<Style id="Style12">
<LineStyle>
<color>7fffffff</color>
<width>0.2</width>
</LineStyle>
<PolyStyle>
<color>66938ab5</color>
<outline>0</outline>
</PolyStyle>
</Style>
<Style id="Style100">
<LineStyle>
<color>7fffffff</color>
<width>0.2</width>
</LineStyle>
<PolyStyle>
<color>66938ab5</color>
<outline>0</outline>
</PolyStyle>
</Style>
<StyleMap id="Style110">
<Pair>
<key>normal</key>
<styleUrl>#Style100</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#Style12</styleUrl>
</Pair>
</StyleMap>
<Folder>
<name>MJESNI_ODBORI</name>
<open>1</open>
<Placemark>
<name>Zamet</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Sveti Nikola</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Mlaka</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Potok</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Turnić</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Podmurvice</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Banderovo</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Škurinjska Draga</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Kantrida</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Grbci</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Srdoči</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Gornji Zamet</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Pehlin</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Škurinje</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Drenova</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Luka</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Pećine</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Krimeja</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Vojak</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Podvežica</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Gornja Vežica</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Brajda-Dolac</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Belveder</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Školjić</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Centar-Sušak</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Bulevard</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Kozala</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Grad Trsat</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Orehovica</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Draga</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Sveti Kuzam</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Brašćine-Pulac</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Pašac</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
****
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Svilno</name>
<styleUrl>#Style11</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
***
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Folder>
</Document>
</Folder>
</kml>
希望有人能想出我的缩放问题在哪里:) tnx