开发者

how to set the center of map in kml file

in http://code.google.com/intl/en/apis/kml/documentation/kml_tut.html

i want to create a kml file , but i can't find how to set a center of map using goo开发者_如何学Cgle-maps-v3

so how to set .

thanks


The Maps API V3 doesn't currently support KML overlays. It is a planned feature, however.


Please try this short example that I use in OpenLayers, a JavaScript map library for expert programmers.

<html>
<head>
<title>My OpenLayers: Google Layer</title>
<link rel="shortcut icon" href="http://www.gis.com.my/logo.ico" type="image/x-icon"/>
<link rel="stylesheet" href="http://openlayers.org/api/theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css" />
<!-- this gmaps key generated for http://localhost:8080/geoserver/ -->
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAl9RMqSzhPUXAfeBCXOussRTQDbvAygy0cfGJr8dEMAYKf3RWNBQqP9mjKIsqTfmAlz5LOJ3Xpy5s4w'></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init() {
// Create the map object
map = new OpenLayers.Map('map');
// Create a Google layer
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
// Add layer to map
map.addLayer(gmap);
// Zoom to Kuala Lumpur, Malaysia
map.setCenter(new OpenLayers.LonLat(101.686855,3.139003), 13);         
}
</script>
</head>
<body onload="init()">
<h1 id="title">My OpenLayers: Google Layer</h1>
<div id="map" style='width: 700px; height: 700px'></div>
</body>
</html>

Notice that the google-maps-v3 is forced to be center. As you can see in the following codes I made: map.setCenter(new OpenLayers.LonLat(101.686855,3.139003), 13);

The LonLat is located in Kuala Lumpur. Bear in mind that it is completely different from your schooldays geography subject, as longitude is x-coordinate. and latitude is y-coordinate. Please refer Cartesian coordination principle.

Good luck.


Regards,

zearth

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜