[OpenLayers-Users] cannot call method cotains lonlat of null

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Thu Jun 2 11:01:41 EDT 2011


Hi all,

I'm sure there's a something elementary that I'm missing here, but I can't
seem to figure this out...

I'm trying to set up a simple map centered on specific lon lat. The error
provided by chrome is that it can't call method 'containslatlon' of null.
I'm not sure what I'm doing wrong here, but the script gives me the map and
control, but no layers. thanks in advance.

<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#map{
width: 400px;
height: 400px;
}
</style>

<script type="text/javascript" src="
http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="OpenLayers-2.11-rc1/OpenLayers.js"
type="text/javascript"></script>
<script src="modernizr-1.7.min.js" type="text/javascript"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js
"></script>
 <script type="text/javascript">
        // <![CDATA[
function initGIS(){
//Map
var map= new OpenLayers.Map('map',
{
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.ScaleLine()],
sphericalMercator: true,
  maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
  maxResolution: 156543.0399,
  numZoomLevels: 19,
  units: 'm',
//   projection: new OpenLayers.Projection("EPSG:900913"),
//   displayProjection: new OpenLayers.Projection("EPSG:4326")
}
);
 //Google BaseLayer
var mapnik = new OpenLayers.Layer.OSM();
        map.addLayers(mapnik);
// var google_map = new OpenLayers.Layer.Google('Google Maps',{});
    var markers=new OpenLayers.Layer.Markers("Markers");
map.addLayers(mapnik, markers);

map.setCenter(
    new OpenLayers.LonLat(38.65, -90.72).transform(new
OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913")
    ), 12
);
}
//]]>
</script>
</head>
<body onLoad="initGIS()">
<div id="map"></div>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110602/744500ce/attachment.html


More information about the Users mailing list