使用Phonegap Build后,谷歌地图将不会显示在手机上
Google maps wont display on mobile after using Phonegap Build
我的谷歌地图在Firefox中运行良好,但当我为移动设备构建它时。地图根本无法显示或加载,遗憾的是,我的编码经验和知识都很贫乏,仍然没有找到解决方案。。。有人知道问题出在哪里吗?如果需要,我可以发布更多代码
var map, places, iw;
var markers = [];
var autocomplete;
var defaultLatLng = new google.maps.LatLng(34.0983425, -118.3267434);
var myLatlng = new google.maps.LatLng(37.783259, -122.402708);
function initialize() {
var myOptions = {
zoom: 17,
//center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords
.latitude, position.coords.longitude);
map.setCenter(initialLocation);
map.setZoom(16);
var marker = new google.maps.Marker({
position: initialLocation,
title: "You are here!"
});
marker.setMap(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
places = new google.maps.places.PlacesService(map);
google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
autocomplete = new google.maps.places.Autocomplete(document.getElementById(
'autocomplete'));
google.maps.event.addListener(autocomplete, 'place_changed', function() {
showSelectedPlace();
});
}
在初始化之前需要使用"插件"
即:plugin.google.maps.Map(document.getElementById("Map_canvas");
类似于其他初始化
var map, places, iw;
var markers = [];
var autocomplete;
var defaultLatLng = new plugin.google.maps.LatLng(34.0983425, -118.3267434);
var myLatlng = new plugin.google.maps.LatLng(37.783259, -122.402708);
function initialize() {
var myOptions = {
zoom: 17,
//center: myLatlng,
mapTypeId: plugin.google.maps.MapTypeId.ROADMAP
}
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new plugin.google.maps.LatLng(position.coords
.latitude, position.coords.longitude);
map.setCenter(initialLocation);
map.setZoom(16);
var marker = new plugin.google.maps.Marker({
position: initialLocation,
title: "You are here!"
});
marker.setMap(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
places = new google.maps.places.PlacesService(map);
plugin.google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
autocomplete = new plugin.google.maps.places.Autocomplete(document.getElementById(
'autocomplete'));
plugin.google.maps.event.addListener(autocomplete, 'place_changed', function() {
showSelectedPlace();
});
}
至少
-
var defaultLatLng=新的google.maps.LatLng(34.0983425,-118.3267434);var myLatlng=新的google.maps.LatLng(37.783259,-122.402708);
应该放在initialize()内
-
中心:myLatlng
不应该被评论掉
-
应该有以下css样式
html,正文{高度:100%;}
地图{
height: 100%;
}
相关文章:
- 从桌面读取python文件时高亮显示代码
- 向下滚动时隐藏菜单,向上滚动时显示,适用于Chrome,不适用于Safari(手机)
- 模态未在使用 Twitter Bootstrap 3.0 的手机上显示
- 如何在 jquery 手机中显示之前在页面中设置选择框的值
- Jquery日期选择器在手机和PC上显示不同的日期
- 为什么对于一个手机号码,这个数据表没有显示任何结果
- 当我在智能手机上显示时,将悬停添加到我的页面
- Phonegap不会在手机中显示谷歌地图
- jquery.hide()函数-隐藏手机,显示桌面
- 自定义谷歌地图不能在手机和平板电脑上显示
- 需要显示关于手机的验证错误消息
- Popcorn.js:手机浏览器YouTube "play"按钮不显示
- 当我点击html输入时,禁用手机键盘的显示
- 强制safari在智能手机上始终显示顶部栏
- 我的谷歌地图javascript代码显示在桌面浏览器,但不是我的手机浏览器
- 当用户想要改变手机方向时,我的应用显示错误的UI.Android
- "旧的“;当通过javascript选中时,手机不会显示复选框复选标记
- 如何在手机浏览器中显示Base64编码的pdf;t有pdf组件
- 如何显示带有街道,城市和国家/地区的手机的当前位置
- 如何显示html内容仅在平板电脑上,而不是在手机或桌面