Google maps api 3 谷歌地图API 3-禁用移动
希望在移动设备上浏览时禁用谷歌地图。如果浏览器窗口为600px或更低,则当前正在运行CSS以隐藏divGoogle maps api 3 谷歌地图API 3-禁用移动,google-maps-api-3,Google Maps Api 3,希望在移动设备上浏览时禁用谷歌地图。如果浏览器窗口为600px或更低,则当前正在运行CSS以隐藏div @media only screen and (max-width: 600px) { .mapCanvas { display: none; } } 如果浏览器为600px或更小,如何禁止JS查询Google Maps API 这样,当地图甚至没有显示时,它就不会查询API服务器 <div id="mapCanvas"></div>
@media only screen and (max-width: 600px) {
.mapCanvas {
display: none;
}
}
如果浏览器为600px或更小,如何禁止JS查询Google Maps API
这样,当地图甚至没有显示时,它就不会查询API服务器
<div id="mapCanvas"></div>
<script>
function initMap() {
var map;
var bounds = new google.maps.LatLngBounds();
var mapOptions = {
mapTypeId: 'roadmap'
};
// Display a map on the web page
map = new google.maps.Map(document.getElementById("mapCanvas"), mapOptions);
map.setTilt(50);
// Multiple markers location, latitude, and longitude
var markers = [ <?php echo $js_markers; ?>
];
// Info window content
var infoWindowContent = [ <?php echo $js_content; ?>
];
// Add multiple markers to map
var infoWindow = new google.maps.InfoWindow(), marker, i;
// Place each marker on the map
for( i = 0; i < markers.length; i++ ) {
var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
bounds.extend(position);
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][0]
});
// Add info window to marker
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infoWindow.setContent(infoWindowContent[i][0]);
infoWindow.open(map, marker);
}
})(marker, i));
// Center the map to fit all markers on the screen
map.fitBounds(bounds);
}
// Set zoom level
var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) {
this.setZoom(7);
google.maps.event.removeListener(boundsListener);
});
}
// Load initialize function
google.maps.event.addDomListener(window, 'load', initMap);
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=???&callback=initMap"></script>
函数initMap(){
var映射;
var bounds=new google.maps.LatLngBounds();
变量映射选项={
mapTypeId:“路线图”
};
//在网页上显示地图
map=new google.maps.map(document.getElementById(“mapCanvas”)、mapOptions);
地图设置倾斜(50);
//多个标记位置、纬度和经度
变量标记=[
];
//信息窗口内容
var infoWindowContent=[
];
//向地图添加多个标记
var infoWindow=new google.maps.infoWindow(),marker,i;
//将每个标记放在地图上
对于(i=0;i
如果google maps API JS文件是移动的,则不包括该文件
差不多
if (typeof window.orientation !== 'undefined') { ... }