旋转谷歌地图嵌入在html中
Rotating google map embedded in html
我将制作一个应用程序,该应用程序具有显示嵌入式Google地图的特殊部分。起初一切正常,但是当我向后旋转设备时,地图超出了定义的宽度并丢失了其css类(它不能应用我使用的220px的宽度)。
{//无论如何,当我触摸地图时,它会没问题,它会达到它的宽度//}{//我正在使用 Twitter Bootstrap//}
我的这个大问题的解决方案是什么?
我正在等待你的友好答复。
这是嵌入式谷歌地图:
<article class="container">
.
.
.
...( some tags go here )
<section class="span12">
<div class="map">
<iframe width="80%" height="50%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&ll=39.6846,-104.88802&spn=0.088114,0.209255&t=m&z=13&output=embed">
</iframe>
</div>
</section>
</article>
这是我正在使用的 css 类:
@media (max-width: 400px) {
.map {width: 220px;}
}
Heh :-D我终于找到了解决方案:
iframe HTML5标签在这方面是无用的,因为它不支持设备方向。所以它必须被删除,我用一个 id="mapDiv" 的div 代替:
<body onLoad="initialize()"> <!-- Important -->
<article class="container">
.
.
.
...( some tags go here )
<section class="span12">
<div id="mapDiv"> </div> <!-- Changed -->
</section>
</article>
</body>
根据Sven Bieder的评论,我像这样使用谷歌地图API:
/*Added javascript*/
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var position = new google.maps.LatLng(38.89655520572012, -77.03372955322266); /*Here is the coordinates of the specific place we want to mark on map*/
var myOptions = {
zoom: 15,
center: position,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
var map = new google.maps.Map(
document.getElementById("mapDiv"), myOptions);
var marker = new google.maps.Marker({
position: position,
map: map,
title:"We are here.",
});
}
</script>
好吧,设备方向问题现在已经解决了:-)
以下是一些用于 #mapDiv 的可选 CSS:
#mapDiv {
width: 100%;
height: 300px;
margin: auto;
-moz-box-shadow: 1px 2px 12px #999999;
-webkit-box-shadow: 1px 2px 12px #999999;
border-radius: 8px;
}
添加此样式将旋转div
div
{
transform:rotate(7deg);
-ms-transform:rotate(7deg); /* IE 9 */
-moz-transform:rotate(7deg); /* Firefox */
-webkit-transform:rotate(7deg); /* Safari and Chrome */
-o-transform:rotate(7deg); /* Opera */
}
<div style="transform:rotate(90deg); -ms-transform:rotate(90deg); /* IE 9 */ -moz-transform:rotate(90deg); /* Firefox */ -webkit-transform:rotate(90deg); /* Safari and Chrome */ -o-transform:rotate(90deg); /* Opera */" class="map">
<iframe width="80%" height="50%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&ll=39.6846,-104.88802&spn=0.088114,0.209255&t=m&z=13&output=embed">
</iframe>
</div>
相关文章:
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 谷歌应用程序脚本html服务和加载谷歌地图javascript api V3
- 旋转谷歌地图嵌入在html中
- 如何将纬度经度从HTML表单传递到谷歌地图
- 谷歌地图/融合表Javascript HTML赢得't显示/可视化所有多边形数据(通过色标)
- 在谷歌地图HTML中简单地添加KML图层
- 是否可以在单个html文件中添加两个谷歌地图API(绘图和几何)
- 如何在 html 中的谷歌地图中默认放大
- 谷歌地图未显示在 HTML
- 谷歌地图只在iPad上导致不可见的html元素,奇怪的行为为什么
- 通过在谷歌地图HTML中单击来获取某个点的纬度和经度
- 通过单击HTML链接在谷歌地图上显示信息窗口
- 将两个谷歌地图添加到一个HTML页面上
- 将HTML链接添加到谷歌地图圆圈元素
- 如何在谷歌地图上制作一组标记,从html中获取地址
- 谷歌地图API JavaScript不在html文件中运行,但在w3school中运行
- 可以'不要在HTML中查看谷歌地图,Cordova
- 将谷歌地图多段线转换为html画布线
- 谷歌地图库位置和几何图形在一个HTML页面中协同工作
- 如何从html表单获取纬度经度值到谷歌地图