On Feb 25, 2011, at 11:25 AM, ext Leigh Holcombe wrote:

> Hello,
> I'm a new user of OpenLayers, with not much JavaScript or Ajax programming 
> experience.  I thought I was starting to get the hang of the API, but then I 
> came across an error.  This error shows up in the Firefox error console, and 
> an empty map-sized container is shown:
> 
> template.replace is not a function
> http://www.openlayers.org/api/OpenLayers.js
> Line: 102
> 
> Can anyone shed some light on what might be causing this?  My humble code, 
> relying heavily on various samples and tutorials, is below:

The OSM layer is a subclass of XYZ, and therefore has a constructor that 
takes three options:

Parameters
name    {String}
url     {String}
options {Object} Hashtable of extra options to tag onto the layer

You have passed an object to the second option (url), and when it
tries to call the template replacement on that non-string, you get
an error. 

Since the OSM layer is already a sphericalMercator layer, you can
simply remove the second argument to your OSM layer, and this should
solve this problem.

-- Chris

> 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
> 
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to