Google地图缩放控件和标记消失
我遇到了两个非常奇怪的谷歌地图问题,这些问题似乎只发生在Chrome / Mac和Chrome / Windows上
如果您点击位于科罗拉多州的第一个引脚并尝试平移地图,将鼠标移动到右侧,您会注意到变焦控制将开始消失。 我已经尝试用最大宽度修复它:无; 所以这不是同一个错误。
如果您点击位于斯科普里的右侧标记,您会注意到标记将在缩放级别20消失
更新:如果我禁用Chrome上的硬件加速,这两个错误都是固定的,所以我认为它比谷歌地图更像一个Chrome问题。
这里是一个jsfiddle链接来重现问题http://jsfiddle.net/sokarovski/rx74P/2/
var posSkopje = new google.maps.LatLng(42.007652282715,21.372894287109034);
var posColorado = new google.maps.LatLng(38.960487365723,-104.76946258545001);
google.maps.visualRefresh = false;
var map = new google.maps.Map(document.getElementById("map_canvas"), {
center: new google.maps.LatLng(0, 0),
zoom: 3,
mapTypeId: google.maps.MapTypeId.HYBRID,
maxZoom: 20
});
var markerSkopje = new CustomMarker('img.svg');
markerSkopje.setPosition(posSkopje);
markerSkopje.setMap(map);
var markerColorado = new CustomMarker('img.svg');
markerColorado.setPosition(posColorado);
markerColorado.setMap(map);
var zoomOnClick = function(arg1) {
map.setCenter(this.getPosition());
map.setZoom(22);
}
google.maps.event.addListener(markerColorado, 'open', jQuery.proxy(zoomOnClick, markerColorado));
google.maps.event.addListener(markerSkopje, 'open', jQuery.proxy(zoomOnClick, markerSkopje));
这个帖子挺旧的,但问题仍然存在。 对于其他人来说,磕磕绊绊; 你可以这样做:
从google制作Markermanager.js的本地副本并修改此行(第107行)
从:
me.maxZoom_ = opt_opts.maxZoom || 19;
至:
me.maxZoom_ = opt_opts.maxZoom || 21;
代码中的一些问题看这个
//=========== > Custom Marker Class
function CustomMarker(opts) {
this.location_ = null;
this.div_ = null;
this.inner_ = null;
this.opts = {
image: null
}
this.constructor = function(image) {
this.inner_ = document.createElement('img');
jQuery(this.inner_).addClass('thumb').click(jQuery.proxy(this.onPinClick, this));
if (image) this.setImage(image);
}
this.setPosition = function(ll) {
this.location_ = ll;
}
this.getPosition = function() {
return this.location_;
}
this.onAdd = function() {
var div = document.createElement('div');
div.style.border = "none";
div.style.borderWidth = "0px";
div.style.position = "absolute";
div.appendChild(this.inner_);
this.div_ = div;
var panes = this.getPanes();
panes.overlayMouseTarget.appendChild(div);
}
this.onPinClick = function(e) {
google.maps.event.trigger(this, 'open');
}
this.draw = function() {
var overlayProjection = this.getProjection();
if (overlayProjection) {
var pixPosition = overlayProjection.fromLatLngToDivPixel(this.location_);
this.div_.style.left = (pixPosition.x ) + "px";
this.div_.style.top = (pixPosition.y) + "px";
}
}
this.setImage = function(image) {
this.inner_.src = image;
}
this.constructor.apply(this, arguments);
}
CustomMarker.prototype = new google.maps.OverlayView();
//=========== > Initialization
var posSkopje = new google.maps.LatLng(42.007652282715,21.372894287109034);
var posColorado = new google.maps.LatLng(38.960487365723,-104.76946258545001);
var map = new google.maps.Map(document.getElementById("map_canvas"), {
center: new google.maps.LatLng(0, 0),
zoom: 3,
mapTypeId: google.maps.ROADMAP,
maxZoom: 20
});
var markerSkopje = new CustomMarker('http://www.gnhl.ca/images/pushed-pin-hi.png');
markerSkopje.setPosition(posSkopje);
markerSkopje.setMap(map);
var zoomOnClick = function(arg1) {
map.setCenter(this.getPosition());
map.setZoom(20);
}
google.maps.event.addListener(markerSkopje, 'open', jQuery.proxy(zoomOnClick, markerSkopje));
链接地址: http://www.djcxy.com/p/81583.html