[OpenLayers-Users] Error: "template.replace is not a function"

daniel.smith1 daniel.smith1 at maine.edu
Mon Jun 28 13:02:23 EDT 2010


I'm currently making a switch to a newer version of OpenLayers so I am able
to use an OSM base layer.  I am getting the error "template.replace is not a
function".  The stacktrace in Firebug shows that it is happening when I call
the setcenter function.  Any ideas?

Here is my (simplified) code:

// OpenLayers, settings to avoid pink tiles
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";

// OpenLayers variables
var map;
var source = new OpenLayers.Projection( 'EPSG:900913' );
var dest = new OpenLayers.Projection( 'EPSG:4326' );

// Center of Maine and zoom level in projection 4326
var lonlat = new OpenLayers.LonLat( -69.254782, 45.315687 );
var zoom = 7;

// Create OpenLayers map
function initializeMap(){

//mapWidth and mapHeight calculated

var options = {
  size: new OpenLayers.Size( mapWidth, mapHeight ),
  projection: source,
  displayProjection: dest,
  units: "m",
  maxResolution: 156543.0339,
  maxExtent: new OpenLayers.Bounds( -20037508.34, -20037508.34,
    20037508.34, 20037508.34 ),
  controls: [
   new OpenLayers.Control.MousePosition(),
   new OpenLayers.Control.Navigation(),
   new OpenLayers.Control.PanPanel(),
   new OpenLayers.Control.ZoomPanel()
  ]
 };
 map = new OpenLayers.Map( 'map', options );
 
 OSMBaseLayer = new OpenLayers.Layer.OSM(
   "OSM",
   {numZoomLevels: 20, 'sphericalMercator': true, 'isBaseLayer': true,
   'maxExtent': new OpenLayers.Bounds(-20037508.34, -20037508.34,
    20037508.34, 20037508.34)}
 );
 map.addLayer(OSMBaseLayer);
 
 // Set map center and adjust lat/lon to 900913 projection
 // Clone used with Transform since transform changes underlying Bounds
 map.setCenter(lonlat.clone().transform( dest,source ), zoom );
}

-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Error-template-replace-is-not-a-function-tp5231723p5231723.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list