有人可以指点我一个教程,解释如何在ActionScript 3的Javascript中使用Google Maps API v3吗?我正在努力教自己,但到目前为止没有运气。以下测试程序显示简单的HTML,但不显示Google Map。
<?xml version="1.0" encoding="utf-8"?>
<!-- aircomponents/src/HTMLSimple.mxml -->
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<mx:ControlBar width="100%">
<s:Button label="< Back"
click="content.historyBack();"/>
<s:Button label="Forward >"
click="content.historyForward();"/>
<s:TextInput id="address"
text="{content.location}" width="100%"/>
<s:Button label="Go!"
click="content.location = address.text"/>
</mx:ControlBar>
<s:Group width="100%" height="100%">
<mx:HTML id="content" location="file:///C:/googlemaps.html"/>
</s:Group>
</s:WindowedApplication>
文件C:/googlemaps.html适用于Firefox并包含:
<!DOCTYPE html>
<html>
<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="http://maps.googleapis.com/maps/api/js?key=AIzaSyDfNNCCL7xmvk-gTYmvS_Cy5PZcf5L3j_I&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var myOptions = {
center: new google.maps.LatLng(41., -96),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
答案 0 :(得分:1)
只需使用此库创建带有AS3的Google地图
答案 1 :(得分:0)
正确设置尺寸。如果您使用百分比,则<body>
元素需要宽度,所以
html,body { height: 100%; width:100%; margin: 0; padding: 0 }
#map_canvas { height: 100%; width:100%}
幸运的是,没有必要加载Flash。 :-) 所以你可以删除
s:WindowedApplication ... etc
和所有
<mx>
垃圾: - )