OpenLayers OpenLayers

Ticket #1082: custom_map_layer.2.patch

File custom_map_layer.2.patch, 2.1 kB (added by crschmidt, 1 year ago)
  • tests/Layer/test_Google.html

    old new  
    8585        } 
    8686    } 
    8787 
     88    function test_Layer_Google_setMapType (t) { 
     89        if (validkey) { 
     90            t.plan(3); 
     91            var layer = new OpenLayers.Layer.Google('Goog Layer'); 
     92            layer.map = {'events':{'unregister': function() {}}}; 
     93            layer.loadMapObject(); 
     94            layer.mapObject.getCenter= function()  { return true; } 
     95            layer.mapObject.getMapTypes = function() { return [0, 1]; } 
     96            layer.mapObject.addMapType = function(type) { 
     97                t.eq(type, 5, "new map type passed correctly."); 
     98            } 
     99            layer.mapObject.setMapType = function(arg) {  
     100               t.eq(arg, 5, "got map type");  
     101            } 
     102            layer.type = 5; 
     103            layer.setMapType(); 
     104            layer.mapObject.setMapType = function(arg) {  
     105               t.eq(arg, 0, "got map type");  
     106            } 
     107            layer.type = 0 
     108            layer.setMapType(); 
     109             
     110        } else { 
     111            t.plan(0); 
     112            t.debug_print("Google tests can't be run from " + 
     113                          window.location.host); 
     114        } 
     115    } 
     116 
    88117    function test_04_Layer_Google_Translation_pixel (t) { 
    89118        if(validkey) { 
    90119            t.plan( 4 ); 
  • lib/OpenLayers/Layer/Google.js

    old new  
    151151     */ 
    152152    setMapType: function() { 
    153153        if (this.mapObject.getCenter() != null) { 
     154             
     155            // Support for custom map types. 
     156            if (OpenLayers.Util.indexOf(this.mapObject.getMapTypes(), 
     157                                        this.type) == -1) { 
     158                this.mapObject.addMapType(this.type); 
     159            }     
     160 
    154161            this.mapObject.setMapType(this.type); 
    155162            this.map.events.unregister("moveend", this, this.setMapType); 
    156163        }