最近开发离线版的google地图,在网上下载了google地图离线包,解压出来后可以实现基本功能,但是地图没有连续的拼接在一起,不应该显示图片的地方也显示了图片如下图所示
我想要的结果是:谷歌地图google地图地图google离线

解决方案 »

  1.   

    我现在只能通过设定中心位置,之后设置东北和西南的经纬度来控制中心在此位置内,具体代码如下:
    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));
    });
    等待楼主所描述的方案!
      

  2.   

    解决了图片显示不正确的问题代码如下:
    <img src="应该显示的路径" onerror="javascript:this.src='默认显示的路径'" />
      

  3.   

    看看这个,官网的例子:
    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);