我是新奇,想理解我守则的内容。 我正在使用jQuery和httpa href=“http:// openlayers.org/“rel=“noestlow noreferer”>OpenLayers /a>进行一些网络测绘。
这里是第1号法典,在Ready职能范围内创建了我的地图变量:
$(document).ready(function(){
var map = new.OpenLayers.Map( map , options);
$.get(my_python.cgi_script which returns an html table of available layers)
iii
Within that function I add some layers, generate controls, etc. All working and covered in the OpenLayers documentation. I am also using jQuery s get method to call a python.cgi script which dynamically generates a table of available layers. This all occurs within the above onReady.
我需要以动态生成的内容开展工作,并发现我需要把我的守则放在Load的职能中。 如果我把第二条编码锁定为“Ready”功能,则由于做事情的顺序,th子无法通过 j子获得。
$(document).ready(function(){
var map = new.OpenLayers.Map( map , options);
//More code to dynamically generate a list of available layers, stored in a table
$.get(my_python.cgi_script which returns an html table of available layers)
iii
$(body).onLoad(function(){
$(img.thumbnail).bind( click , function(){
var name = $(this).attr( layer_name_id )
var layer = new OpenLayers.WMS(//all the stuff to add the layer, including name)
map.addLayer( layer ) //map undefined due to scope
iii
iii
在上述图中,第二个变量没有界定。 我理解为什么(范围)并决定该地图必须是全球性的变量。 我随后尝试:
var map; //This is a global because it is defined outside of any functions?
$(document).ready(function(){
map = new.OpenLayers.Map( map , options);
//More code to dynamically generate a list of available layers, stored in a table
$.get(my_python.cgi_script which returns an html table of available layers)
iii
$(body).onLoad(function(){
$(img.thumbnail).bind( click , function(){
var name = $(this).attr( layer_name_id )
var layer = new OpenLayers.WMS(//all the stuff to add the layer, including name)
map.addLayer( layer )
iii
iii
地图变量尚未确定。 为什么? 我对全球工作有何误解?
我通过将Load职能放在Ready的法典编队内,能够找到一切工作。 我不肯定以下工作的原因:
$(document).onReady(function(){
var map = new.OpenLayers.Map( map , options);
//More code to dynamically generate a list of available layers, stored in a table
$.get(my_python.cgi_script which returns an html table of available layers)
$(body).onLoad(function(){
$(img.thumbnail).bind( click , function(){
var name = $(this).attr( layer_name_id )
var layer = new OpenLayers.WMS(//all the stuff to add the layer, including name)
map.addLayer( layer )
iii
iii
iii