最近开发离线版的google地图,在网上下载了google地图离线包,解压出来后可以实现基本功能,但是地图没有连续的拼接在一起,不应该显示图片的地方也显示了图片如下图所示
我想要的结果是:谷歌地图google地图地图google离线
我想要的结果是:谷歌地图google地图地图google离线
解决方案 »
- object.focus()疑问
- 有谁帮帮我,关于IE,FF兼容的问题
- 怎样取div控件里的text控件的id值
- 动态的增加文本域和文本框??????最好有完整的例子
- 高分求助在线等:type=file选择图片后,想在页面显示出指定的大小来,让图片不失真,有什么好办法?
- 菜鸟,问代码解释!对你们来说很简单!
- 急:JavaScipt读文件的方法有什么?
- 一个初用JavaScript程序员的困惑?
- 还有比这简单的问题???~!~
- 怎么实现HTML中3张图片点击都有拉开帷幕计入另外个网页的效果,求帮忙 ,急!!!!!!!!!
- 关闭网页时dwr的ScriptSessionListener销毁ScriptSession会延迟5分钟执行
- 求解一个果JS引用 问题
var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(
41.74673, 123.35724), new google.maps.LatLng(41.87365,
123.50006));//设定地图范围
google.maps.event.addListener(map,'dragend',function() {//设置地图拖拽范围(按东北-西南定制的矩形)
if (bounds.contains(map.getCenter())) {return;}
var c = map.getCenter(), x = c.lng(), y = c.lat(),
maxX = bounds.getNorthEast().lng(),
maxY = bounds.getNorthEast().lat(),
minX = bounds.getSouthWest().lng(),
minY = bounds.getSouthWest().lat();
if (x < minX) {
x = minX;
}
if (x > maxX) {
x = maxX;
}
if (y < minY) {
y = minY;
}
if (y > maxY) {
y = maxY;
}
map.setCenter(new google.maps.LatLng(y, x));
});
等待楼主所描述的方案!
<img src="应该显示的路径" onerror="javascript:this.src='默认显示的路径'" />
function TxtOverlay(pos, txt, cls, map){
this.pos = pos;
this.txt_ = txt;
this.cls_ = cls;
this.map_ = map;
this.div_ = null;
this.setMap(map);
}
TxtOverlay.prototype = new google.maps.OverlayView();
TxtOverlay.prototype.onAdd = function(){
var div = document.createElement('DIV');
div.className = this.cls_;
div.innerHTML = this.txt_;
this.div_ = div;
var overlayProjection = this.getProjection();
var position = overlayProjection.fromLatLngToDivPixel(this.pos);
div.style.left = position.x + 'px';
div.style.top = position.y + 'px';
var panes = this.getPanes();
panes.floatPane.appendChild(div);
}
TxtOverlay.prototype.draw = function(){
var overlayProjection = this.getProjection();
var position = overlayProjection.fromLatLngToDivPixel(this.pos);
var div = this.div_;
div.style.left = position.x + 'px';
div.style.top = position.y + 'px';
}
TxtOverlay.prototype.onRemove = function(){
this.div_.parentNode.removeChild(this.div_);
this.div_ = null;
}
TxtOverlay.prototype.hide = function(){
if (this.div_) {
this.div_.style.visibility = "hidden";
}
}
TxtOverlay.prototype.show = function(){
if (this.div_) {
this.div_.style.visibility = "visible";
}
}
TxtOverlay.prototype.toggle = function(){
if (this.div_) {
if (this.div_.style.visibility == "hidden") {
this.show();
}
else {
this.hide();
}
}
}
TxtOverlay.prototype.toggleDOM = function(){
if (this.getMap()) {
this.setMap(null);
}
else {
this.setMap(this.map_);
}
}
var map;
function initialize(){
var latlng = new google.maps.LatLng(37.9069, -122.0792);
var myOptions = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
txt = new TxtOverlay(latlng,"","",map )
}
google.maps.event.addDomListener(window, 'load', initialize);