[OpenLayers-Users] OpenLayers error - template.replace is not a function

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Fri Feb 25 07:06:09 EST 2011


On Feb 25, 2011, at 11:52 AM, ext Leigh Holcombe wrote:
>>> function init() {
>>> 
>>> Proj4js.defs["EPSG:26904"]="+proj=utm +zone=4 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
>>> var x = 626910.977254;
>>> var y = 2358256.879039;
>>> var mercator = new Proj4js.Proj("EPSG:90013");
>>> var utm4n = new Proj4js.Proj("EPSG:26904");
>>> var map = new OpenLayers.Map('testmap', {projection: mercator});
>>> var osm = new OpenLayers.Layer.OSM('osmlayer', {sphericalMercator: true});
>>> var point = new Proj4js.Point(x,y);
>>> map.addLayer(osm);
>>> map.addControl(new OpenLayers.Control.PanZoomBar());
>>> map.setCenter(Proj4js.transform(utm4n, mercator, point));
>>> map.zoomTo(15);
>>> }
>>> 
>>> Regards,
>>> Leigh Holcombe
> 
> 
> Thanks, Chris.  I modified the line in question, it now reads:
> 
> var osm = new OpenLayers.Layer.OSM('osmlayer');
> 
> Good news is that this cleared the template.replace error.  Unfortunately, I am still getting an empty map.

Nick Whitelegg's advice is probably the next thing to look at in that case:
you have a typo in your proj4js proj for mercator, which should be
900*9*13.

Note that you should probably also not be using these weird proj4js points;
you should use an OpenLayers.LonLat and OpenLayers.Projection objects
instead like:

 var center = new OpenLayers.LonLat(x,y).transform(new OpenLayers.Projection("EPSG:26904"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter(center, 15)

-- Chris

> 
> 



More information about the Users mailing list