Google maps IBM Grails Google Maps V2 for V3示例
我一直在学习IBM的Grails和Google地图教程 我注意到它是针对谷歌地图API v2的。我试图用v3语法做同样的事情,但我显然做错了什么。我在教程中得到了这个例子,所以它从db中得到了lat和lng。我现在在办公室,没有可以粘贴的示例 但问题是,我将如何编写下面的代码来使用GoogleMapsV3。我一到家就更新帖子Google maps IBM Grails Google Maps V2 for V3示例,google-maps,grails,Google Maps,Grails,我一直在学习IBM的Grails和Google地图教程 我注意到它是针对谷歌地图API v2的。我试图用v3语法做同样的事情,但我显然做错了什么。我在教程中得到了这个例子,所以它从db中得到了lat和lng。我现在在办公室,没有可以粘贴的示例 但问题是,我将如何编写下面的代码来使用GoogleMapsV3。我一到家就更新帖子 <script type="text/javascript"> var usCenterPoint = new GLatLng(39.833333,
<script type="text/javascript">
var usCenterPoint = new GLatLng(39.833333, -98.583333)
var usZoom = 4
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"))
map.setCenter(usCenterPoint, usZoom)
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
<g:each in="${airportList}" status="i" var="airport">
var point${airport.id} = new GLatLng(${airport.lat}, ${airport.lng})
var marker${airport.id} = new GMarker(point${airport.id})
marker${airport.id}.bindInfoWindowHtml("${airport.iata}<br/>${airport.name}")
map.addOverlay(marker${airport.id})
</g:each>
}
}
var usCenterPoint=新玻璃(39.833333,-98.583333)
var usZoom=4
函数加载(){
if(GBrowserIsCompatible()){
var map=新的GMap2(document.getElementById(“map”))
地图设置中心(usCenterPoint、usZoom)
addControl(新的GlargeMappControl());
addControl(新的GMapTypeControl());
var point${airport.id}=newglatlng(${airport.lat},${airport.lng})
var marker${airport.id}=新的GMarker(点${airport.id})
标记${airport.id}.bindInfoWindowHtml(${airport.iata}
${airport.name})
map.addOverlay(标记${airport.id})
}
}
我所要做的就是在地图上显示airportList中的标记。
谢谢 我是这样解决的。可能还有其他解决方案,但这是可行的
function initialize() {
var myOptions = {
som options...
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, markers);
var markers = [];
g:each in="${airportList}" status="i" var="airport"
var latlng = new google.maps.LatLng(${airport.lat}, ${airport.lng});
var marker${airport.id} = new google.maps.Marker({
position: latlng,
map: map,
title:"${airport.name}",
icon: 'http://google-maps-icons.googlecode.com/files/factory.png',
});
g:each
希望这有帮助!您必须打开和关闭g:each标记,但如果我添加“”则代码消失:我是这样解决的。可能还有其他解决方案,但这是可行的
function initialize() {
var myOptions = {
som options...
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, markers);
var markers = [];
g:each in="${airportList}" status="i" var="airport"
var latlng = new google.maps.LatLng(${airport.lat}, ${airport.lng});
var marker${airport.id} = new google.maps.Marker({
position: latlng,
map: map,
title:"${airport.name}",
icon: 'http://google-maps-icons.googlecode.com/files/factory.png',
});
g:each
希望这有帮助!您必须打开和关闭g:each标记,但如果我添加“”则代码消失:新的google.maps.Map正在我的grails应用程序中解析。我需要添加任何jar文件吗?或者任何我已经添加的地理位置插件new google.maps.Map正在我的grails应用程序中解析。我需要添加任何jar文件吗?或者任何我已经添加了地理位置插件的插件