【发布时间】:2015-11-06 01:08:03
【问题描述】:
我尝试在我网站的单个页面上添加两个谷歌地图,但它显示在现有地图上。如何在单页上一张一张添加两张谷歌地图?
这里是代码......
<div class="map">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<div style="overflow:hidden;height:500px;width:1600px;">
<div id="gmap_canvas" style="height:400px;width:1130px;">
</div>
<style>
#gmap_canvas img {
max-width: none!important;
background: none!important
}
</style>
<script type="text/javascript">
function init_map() {
var myOptions = {
zoom: 18,
center: new google.maps.LatLng(10.968203873914659, 79.39677137070021),
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(10.968203873914659, 79.39677137070021)
});
infowindow = new google.maps.InfoWindow({
content: "<b>Code Shoppy</b><br/>Vatti pilaiyar Koil Road<br/>Upstairs of Chola Ceramics<br/>Kumbakonam-612001"
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
});
infowindow.open(map, marker);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
</div>
</div>
<div class="container">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<div style="overflow:hidden;height:500px;width:600px;">
<div id="gmap_canvas" style="height:500px;width:600px;"></div>
<style>
#gmap_canvas img {
max-width: none!important;
background: none!important
}
</style>
<script type="text/javascript">
function init_map() {
var myOptions = {
zoom: 16,
center: new google.maps.LatLng(10.7904833, 78.70467250000002),
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(10.7904833, 78.70467250000002)
});
infowindow = new google.maps.InfoWindow({
content: "<b>Power Integrated Solutions</b><br/>10A/3 Radhkrishnan Colony, Sasthri Road,<br/> Trichy-17"
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
});
nfowindow.open(map, marker);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
</div>
</div>
</div>
【问题讨论】:
-
您的代码有问题... 嗯,没有代码
标签: javascript google-maps google-maps-api-3