首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌地图V3地图在chrome中可以使用,在移动safari中为空白

谷歌地图V3地图在chrome中可以使用,在移动safari中为空白
EN

Stack Overflow用户
提问于 2011-09-03 18:05:30
回答 1查看 473关注 0票数 0

这段代码在Chrome中运行得很好,但在移动Safari中是空白的。尝试将我的map设置为固定尺寸,但似乎没有帮助。

代码语言:javascript
复制
<div id="map-overflow" style="overflow: hidden; padding: 0; border: 0;" class="notransform">
<div id="map" style="margin-left: -20px; margin-top: -20px;" class="notransform"></div>
<script type="text/javascript">
function map_initialize() { 
// when first loading the window make sure map_canvas & map are set to appropriate
// dimensions based on the iphone's orientation when loading the map
if ((window.orientation == (-90)) || (window.orientation == (90))) {
var width = 520; var height = 285;
$('#map').css("width",width+"px");
$('#map').css("height",height+"px");
$('#map-overflow').css("width",(width-40)+"px");
$('#map-overflow').css("height",(height-10)+"px");
} else {
var width = 360; var height = 435;
$('#map').css("width",width+"px");
$('#map').css("height",height+"px");
$('#map-overflow').css("width",(width-40)+"px");
$('#map-overflow').css("height",(height-10)+"px");
}

if (navigator.geolocation) {navigator.geolocation.getCurrentPosition(function(position)                {  
var point = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);

var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: point,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var memarker = new google.maps.Marker({position:point, map: map,icon:     'http://servername.co.nz/markers/man.png'});
var radius = 25;
var searchUrl = 'maptest.php?lat=' + point.lat() + '&lng=' + point.lng() + '&radius=' +     radius;     
jQuery.get(searchUrl, {}, function(data) {
jQuery(data).find("marker").each(function() {

var marker = jQuery(this);
var name = marker.attr("name");
var address = marker.attr("address"); 
var distance = marker.attr("distance"); 
var latlng = new         google.maps.LatLng(parseFloat(marker.attr("lat")),parseFloat(marker.attr("lng")));
var marker = new google.maps.Marker({position: latlng, map: map,icon:     'http://servername.co.nz/markers/'+marker.attr("markerIcon")});
    google.maps.event.addListener(marker, 'click', function () {
    $('#locationInfo').empty(); 
    $('#locationInfo').show();  
    $('#locationInfo').append("<p>Name:"+name+"</p>");
    $('#locationInfo').append("<p>Address:"+address+"</p>");
    $('#locationInfo').append("<p>Distance:"+distance+"</p>");
      });
  }); 
}); 
});
}
else {
alert('W3C Geolocation API is not available');
} 
}
</script>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-04 07:55:59

好了!为safari关闭了地理定位!实际上没有检测到这一点!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7292460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档