0
我的問題是,我有一些JavaScript代碼,調用谷歌地圖API,並顯示在我的桌面上使用我的瀏覽器查看它時,我正在使用的瀏覽器是谷歌瀏覽器,但當我嘗試查看它使用我的Android手機它不顯示完整,但是當我旋轉我的屏幕,然後它工作正常。谷歌地圖的JavaScript未在手機瀏覽器上完全加載
下面是我的代碼
var markers = new Array();
var map ;
function initialize(locations,firstLat,firstLng,hovericon,zoomLevel) {
var locations = locations;
map = new google.maps.Map(document.getElementById('map_canvas'), {
scrollwheel : false,
zoom : zoomLevel,
center : new google.maps.LatLng(parseFloat(firstLat), parseFloat(firstLng)),
disableDefaultUI : false,
streetViewControl : false,
mapTypeControlOptions : { mapTypeIds: [] },
mapTypeId : google.maps.MapTypeId.ROADMAP
});
map.setOptions({ minZoom: 3, maxZoom: 20 });
var marker, i;
map.setOptions({styles: styles});
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
var markerclusterer = null;
var mc = new MarkerClusterer(map);
for (i = 0; i < Object.size(locations); i++) {
marker = new google.maps.Marker({
position : new google.maps.LatLng(locations[i][1], locations[i][2]),
icon : site_url+'assets/front/images/'+locations[i][4],
map : map,
jobID : locations[i][3],
draggable : false,
originalicon : site_url+'/assets/front/images/'+locations[i][4],
hovericon : site_url+'assets/front/images/'+hovericon,
zIndex : Math.round((locations[i][1], locations[i][2])*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
//alert(this.jobID);
var appElement=document.querySelector('[ng-app=yolomd]');
var $rootscope = angular.element(appElement).scope();
console.log($rootscope);
$rootscope.ismarkerClicked=this.jobID;
$rootscope.$apply();
// window.location.href = this.jobID;
});
google.maps.event.addListener(marker, "mouseover", function() {
this.setIcon(this.hovericon);
});
google.maps.event.addListener(marker, "mouseout", function() {
this.setIcon(this.originalicon);
});
markers.push(marker);
mc.addMarker(marker);
function AutoCenter()
{
var bounds = new google.maps.LatLngBounds();
$.each(markers, function (index, marker) {
bounds.extend(marker.position);
});
map.fitBounds(bounds);
}
if(zoomLevel==10){
AutoCenter();
}
google.maps.event.trigger(map, "resize");
}
}