开发者

Uncaught TypeError: Cannot read property '__e_' of undefined

Although the Map on the page below continues to work fine on most browsers (e.g. FF 3.6, Safari 4 & 5, IE 6 & 7) it comes up blank and appears to cause subsequent JS loading in FF 4, & later versions of Chrome (OSX / WinXP):

http://www.kqed.org/quest

In Firebug on FF I'm seeing the following error, though not reliably:

"Uncaught TypeError: Cannot read property '_e' of undefined"

Also seeing this sometimes:

this.element is undefined

Line 79

This map worked fine for the last 2+ years, I have not modified the code, and only having problems with these recently browser releases.

Any insights?

**update, see code up to aboutline 113; seems I run out of room much past that.


2var TYPES={0:"trail_head",1:"trail"}
3var map_icons={generic:{main:"/quest/map/map_point.png",hl:"/quest/map/map_point_bl.png"},asset:{main:"/quest/map/map_point.png",hl:"/quest/map/map_point_bl.png"},trail:{main:"/quest/map/map_point.png",hl:"/quest/map/map_point_bl.png"},trail_head:{main:"/quest/map/map_point.png",hl:"/quest/map/map_point_bl.png"},slideshow:{main:"/quest/map/slideshow.png",hl:"/quest/map/slideshow_over.png"},radio:{main:"/quest/map/radio.png",hl:"/quest/map/radio_over.png"},television:{main:"/quest/map/tv.png",hl开发者_StackOverflow中文版:"/quest/map/television_over.png"},exploration:{main:"/quest/map/exploration.png",hl:"/quest/map/exploration_over.png"},maps:{main:"/quest/map/exploration.png",hl:"/quest/map/exploration_over.png"},blog:{main:"/quest/map/blog.png",hl:"/quest/map/blog_over.png"}}
4var colors=["#ff852b"];var color_index=0;var templates={generic:"info_template",asset:"info_template",radio:"info_template",television:"info_template",exploration:"info_template",slideshow:"info_template",maps:"info_template",trail:"info_template",trail_head:"info_template",blog:"info_template"}
5var splash="/quest/map/start_quest.png";var splash_hover="/quest/map/start_quest_over.png";var NavControl=StatusClass.create({initialize:function(map){var container=document.qtag("div",{id:"map_nav",className:"customComponent"},document.qtag("div",{id:"map_up",$style:{cursor:"pointer"}}),document.qtag("div",{id:"map_sides",$style:{cursor:"pointer"}},document.qtag("div",{id:"map_left",$style:{cursor:"pointer"}}),document.qtag("div",{id:"map_right",$style:{cursor:"pointer"}})),document.qtag("div",{id:"map_down",$style:{cursor:"pointer"}}),document.qtag("div",{id:"map_plus",$style:{cursor:"pointer"}}),document.qtag("div",{id:"map_minus",$style:{cursor:"pointer"}}));map.getContainer().appendChild(container);GEvent.addDomListener($("map_up"),"click",function(){map.panDirection(0,+1);});GEvent.addDomListener($("map_left"),"click",function(){map.panDirection(+1,0);});GEvent.addDomListener($("map_right"),"click",function(){map.panDirection(-1,0);});GEvent.addDomListener($("map_down"),"click",function(){map.panDirection(0,-1);});GEvent.addDomListener($("map_minus"),"click",function(){try{map.zoomOut();}catch(e){};if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1){map.qmap.redraw_treks();}});GEvent.addDomListener($("map_plus"),"click",function(){try{map.zoomIn();}catch(e){};if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1){map.qmap.redraw_treks();}});this.object=container;},getDefaultPosition:function(){return new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(5,30));}});var TypeControl=StatusClass.create({initialize:function(map,pieces){var container=document.qtag("div",{className:"customComponent"},document.qtag("div",{id:"map_sat"}),document.qtag("div",{id:"map_map"}),document.qtag("div",{id:"map_hyb"}),document.qtag("div",{id:"map_ter"}));listen(container.childNodes[0],"click",function(){try{map.setMapType(G_SATELLITE_MAP);}catch(e){}
6$("map_map").className="off";$("map_hyb").className="off";$("map_sat").className="on";$("map_ter").className="off";});listen(container.childNodes[1],"click",function(){try{map.setMapType(G_NORMAL_MAP);}catch(e){}
7$("map_map").className="on";$("map_hyb").className="off";$("map_sat").className="off";$("map_ter").className="off";});listen(container.childNodes[2],"click",function(){try{map.setMapType(G_HYBRID_MAP);}catch(e){}
8$("map_map").className="off";$("map_hyb").className="on";$("map_sat").className="off";$("map_ter").className="off";});listen(container.childNodes[3],"click",function(){try{map.setMapType(G_PHYSICAL_MAP);}catch(e){}
9$("map_map").className="off";$("map_hyb").className="off";$("map_sat").className="off";$("map_ter").className="on";});map.getContainer().appendChild(container);$('map_sat').className="on";if(pieces==true)
10pieces=['map_sat','map_map','map_hyb','map_ter'];for(var i=0;i<pieces.length;i++)
11$(pieces[i]).show();this.object=container;},getDefaultPosition:function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT);}});function map_icon2(marker,hl){var type=marker.type;var tpl=map_icons[type];if(!tpl)
12return undefined;var img=hl?tpl.hl:tpl.main;var defaults={shadow:"http://labs.google.com/ridefinder/images/mm_20_shadow.png",iconSize:new GSize(30,35),shadowSize:new GSize(30,30),iconAnchor:new GPoint(20,20),infoWindowAnchor:new GPoint(5,5)};if(marker.my_parent.options.points_numbered){var parts=img.split(".");img=parts.splice(0,parts.length-1)+"_"+marker.my_index+"."+parts[parts.length-1];if(!hl){var preload=new Image();parts=tpl.hl.split(".");preload.src=parts.splice(0,parts.length-1)+"_"+marker.my_index+"."+parts[parts.length-1];}}
13for(var k in defaults){if(tpl[k]==undefined)
14tpl[k]=defaults[k];}
15var icon=new GIcon();icon.image=img;for(var k in tpl){icon[k]=tpl[k];}
16return icon;}
17var QuestPointArray=StatusClass.create("array",{set_mode:function(mode){this._mode=mode;for(var idx=0;idx<this.length;idx++){this[idx].set_mode(mode);}},render:function(map){if(this.on_map){for(var idx=0;idx<this.on_map.length;idx++){map.removeOverlay(this.on_map[idx]);}
18this.on_map=[];}
19for(idx=0;idx<this.length;idx++){this[idx].marker(map);}},search:function(p){var ltracker_key=p.lat()+"_"+v.lng();if(!this.ltracker[ltracker_key]){return false;}else{return this.ltracker[ltracker_key];}},push_point:function(v,point_group){if(!this.on_map)
20this.on_map=[];if(!this.redraw_points)
21this.redraw_points=[];if(!this.ltracker)
22this.ltracker={}
23var ltracker_key=v.lat()+"_"+v.lng();if(this.ltracker[ltracker_key]&&point_group==true){this.ltracker[ltracker_key].append(v);return;}else if(this.ltracker[ltracker_key]&&point_group=="warn"){console.log("Point overlap (continue with caution)! Lat: %d, Lng: %d...",v.lat(),v.lng());this.ltracker[ltracker_key]=v;}else{this.ltracker[ltracker_key]=v;}
24v.set_mode(this._mode);v.point_array=this;v.point_array_index=this.length;this.push(v);},splice_point:function(where,length){var ltracker_key=v.lat()+"_"+v.lng();if(this.ltracker[ltracker_key])
25this.ltracker[ltracker_key]=false;this.splice(where,length);for(var idx=0;idx<this.length;idx++){this[idx]._array_index=idx;}}});function included(subject,what){for(var i=0;i<subject.length;i++){if(what==subject[i])
26return true;}
27return false;}
28var title_element;var title_element_exists;var Title=function(point,text){this.text=text;this.point=point;}
29Title.prototype=new GOverlay();Title.prototype.initialize=function(map){var te=document.createElement("div");te.className="map_title";te.style.position="absolute";Element.extend(te);te.hide();map.getPane(G_MAP_MAP_PANE).appendChild(te);this.map_=map;this.div_=te;}
30Title.prototype.copy=function(){return new Rectangle(this.point,this.text);}
31Title.prototype.remove=function(){try{this.div_.parentNode.removeChild(this.div_);}catch(e){}
32title_element_exists=false;}
33Title.prototype.set=function(point,text){this.point=point;this.text=text;this.div_.innerHTML=text;this.redraw(true);this.div_.show();}
34Title.prototype.show=function(){if(this.div_)
35this.div_.show();}
36Title.prototype.hide=function(){if(this.div_)
37this.div_.hide();}
38Title.prototype.redraw=function(force){if(!force)return;var po=this.map_.fromLatLngToDivPixel(this.point);this.div_.style.left=(po.x+15)+'px';this.div_.style.top=(po.y-15)+'px';this.div_.style.zIndex=5000;this.div_.parentNode.style.zIndex=5000;}
39var GMarker2=StatusClass.create({initialize:function(map,point,options){this.map=map;if(!this.map.setTitle){this.map.setTitle=true;title_element=new Title(point,"Initial");}
40this.point=point;this.icon=options.icon;this.roller=options.roller;this.clicker=options.clicker;this.callbacks=options.callbacks||{};this.events=[]
41this.title=options.title;this.setIcon(this.icon,'icon');},addEvents:function(allow){var that=this;if(!allow||included(allow,"click"))
42this.events.push(GEvent.addListener(this.__marker,"click",function(){that.click();}));if(!allow||included(allow,"mouseover"))
43this.events.push(GEvent.addListener(this.__marker,"mouseover",function(){that.mouseover();}));if(!allow||included(allow,"mouseout"))
44this.events.push(GEvent.addListener(this.__marker,"mouseout",function(){that.mouseout();}));},removeEvents:function(){for(var i=0;i<this.events.length;i++)
45GEvent.removeListener(this.events[i]);this.events=[];},click:function(){this.state='click';if(this.callbacks.click)
46this.callbacks.click(this);if(this.clicker)
47this.setIcon(this.clicker,'clicker',["click"]);},mouseover:function(){if(!title_element_exists){title_element_exists=true;this.map.addOverlay(title_element);}
48if(this.callbacks.mouseover)
49this.callbacks.mouseover();this.showTitle();this.state='mouseover';if(this.roller)
50this.setIcon(this.roller,'roller',["mouseout","click"]);},mouseout:function(){if(this.callbacks.mouseout)
51this.callbacks.mouseout(this);this.hideTitle();this.state='normal';this.setIcon(this.icon,'icon');},show:function(){this.setIcon(this.icon,'icon');},hide:function(){this.remove();},remove:function(){if(this.__marker){this.removeEvents();this.map.removeOverlay(this.__marker);}},reset:function(){this.hideTitle();this.setIcon(this.icon,'icon');},showTitle:function(){if(!this.title)return;title_element.set(this.point,this.title);},hideTitle:function(){if(!this.title)return;title_element.hide();},setIcon:function(icon,name,allow){if(this.__icon==icon)
52return;if(this.callbacks.change)
53this.callbacks.change(name,icon);this.remove();this.__marker=new GMarker(this.point,{draggable:false,icon:icon});this.__icon=icon;this.map.addOverlay(this.__marker);this.addEvents(allow);}});var QuestPoint=StatusClass.create(GLatLng.prototype,{initialize:function(){var options=arguments[0];var args=new Array();for(var i=1;i<arguments.length;i++)
54args.push(arguments[i]);this.type=options.type;this.link=options.link;this.human_type=options.human_type;this.resources=options.resources;this.resources_target=options.resources_target;this.active=false;this.state='icon';this.focused=true;GLatLng.apply(this,args);},hide:function(){this.__marker.hide();},show:function(){var that=this;if(this.__marker)
55this.__marker.remove();this.__marker=new GMarker2(this.map,this,{icon:map_icon2(this,false),clicker:map_icon2(this,true),title:((this.resources&&this.resources[0])?this.resources[0].title:null),callbacks:{change:function(icon){that.state=icon;if(icon=='icon')
56that.active=false;},click:function(marker){if(that.active)
57that.goto_resource();that.active=true;if(!that.resources_target)
58that.resources_target=that.my_parent.options.resources_target;for(var idx=0;idx<that.my_parent.points.length;idx++){if(that.my_parent.points[idx].state!='icon')
59that.my_parent.points[idx].__marker.reset();}
60that.my_parent.active=that;that.show_resource();}}});},marker:function(map,hl,force){this.map=map;this.show();},marker_click:function(){this.__marker.click();},goto_resource:function(){if(this.link)
61window.location=this.link;},show_resource:function(){this.visible=true;var text=(new Template(templates[this.type]).render(this));if(this.resources_target){if(typeof(this.resources_target)=="string")
62this.resources_target=$(this.resources_target);this.resources_target.style.display='block';this.resources_target.innerHTML=text.innerHTML;}else{this.__marker.openInfoWindow(text);}}});var QuestTrek2=StatusClass.create({initialize:function(points,path,more,other){this.more=more;this.options=other;this.on_map=[];this.set_points(points);this.set_encoded_path(path);},set_points:function(points){this.point_count=0;this.points=new Array();this.auto_activate=new Array();this.point_count+=points.length;for(var idx=0;idx<points.length;idx++){var point=new QuestPoint(points[idx],points[idx].lat,points[idx].lng);if(points[idx].activate)
63this.auto_activate.push(point);point.my_index=idx;point.my_family=this.points;point.my_parent=this;this.points.push(point);}
64if(this.options&&this.options.resource_grouper&&this.more){if(typeof(this.options.resource_grouper)=='string')
65this.options.resource_grouper=eval(resource_grouper);while(this.more.length>0)
66this.points=this.options.resource_grouper(this.points,this.more.pop());}},activate:function(map){if(this.auto_activate.length==0){this.auto_activate.push(this.points[0]);}
67while(this.auto_activate.length>0){var point=this.auto_activate.pop();point.marker_click(point._marker);}},next:function(){try{this.points[this.active.my_index+1].marker_click();}catch(e){console.error(e)}},previous:function(){try{this.points[this.active.my_index-1].marker_click();}catch(e){console.error(e)}},set_encoded_path:function(path){if(!path)
68return;if(path=="between"){this.encoded_path="between";return;}
69this.encoded_path={};this.encoded_path.points=path;this.encoded_path.levels="";this.encoded_path.options=path.options;if(!path.options)
70this.encoded_path.options={};if(path.levels){this.encoded_path.levels=path.levels;this.encoded_path.points=path.encoded;}else{var idx=0;var len=path.length;do{var idx_start=idx;do{var b=path.charCodeAt(idx++)-63;}while(b>=0x20);do{var b=path.charCodeAt(idx++)-63;}while(b>=0x20);this.encoded_path.levels+="B";}while(idx<len);}},draw:function(map){var that=this;this.map=map;var pl=false;if(color_index>=colors.length)
71color_index=0;for(var idx=0;idx<this.points.length;idx++)
72this.points[idx].marker(map);if(this.encoded_path=="between"){pl=new GPolyline(this.points);}else if(this.encoded_path){pl=new GPolyline.fromEncoded({color:this.encoded_path.options.color||colors[color_index],points:this.encoded_path.points,levels:this.encoded_path.levels,weight:this.encoded_path.options.weight||10,zoomFactor:this.encoded_path.options.zoomFactor||32,numLevels:this.encoded_path.options.numLevels||4});}
73if(pl)
74map.addOverlay(pl);color_index++;},filter:function(type){var visible=[];for(var idx=0;idx<this.points.length;idx++){if(type&&this.points[idx].type!=type){this.points[idx].hide();}else{this.points[idx].show();visible.push(this.points[idx]);}}
75this.center(this.map,visible,true);},center:function(map,others,override){if(this.points.length==0)
76return;var sw=false;var nw=false;var points=this.points;if(others&&!override){for(var i=0;i<others.length;i++){points=points.concat(others[i]);}}else if(others){points=others;}
77if(points.length==1){if(map){map.setCenter(points[0],10);}else{return points[0];}}else{var north=-180;var south=180;var west=180;var east=-180;for(var idx=0;idx<points.length;idx++){var point=points[idx];var lat=point.lat();var lng=point.lng();if(lat<south)south=lat;if(lat>north)north=lat;if(lng<west)west=lng;if(lng>east)east=lng}
78var ne=new GLatLng(north,east);var sw=new GLatLng(south,west);}
79var trek_bounds=new GLatLngBounds(sw,ne);if(map){var map_zoom=map.getBoundsZoomLevel(trek_bounds);try{var tbcenter=trek_bounds.getCenter();map.setCenter(tbcenter,map_zoom);var swp=map.fromLatLngToDivPixel(sw);if(swp.x<20||(this.element.clientHeight-swp.y)<20)
80map.setCenter(tbcenter,map_zoom-1);}catch(e){}}else{return trek_bounds.getCenter();}}});var QuestTrek=StatusClass.create({initialize:function(options){this.info_window=options.target||false;this.path=options.path||new QuestPointArray();this.points=new QuestPointArray();this.point_group=(options.point_group==undefined)?true:options.point_group;this.rsrc_group=options.rsrc_group;this.src=options.src;},mk_point:function(lat,lng,type){type=type||"generic";var p=new GLatLng(lat,lng);p.set_target(this.info_window);p.set_trek(this);p.set_type(type);return p;},set_resources:function(resources){if(this.rsrc_group){for(var idx=0;idx<resources.length;idx++){this.points=this.rsrc_group(this.points,resources[idx]);}}},set_target:function(target){for(var idx=0;idx<this.points.length;idx++){this.points[idx].set_target(target||false);}},move_target:function(to){for(var idx=0;idx<this.points.length;idx++){this.points[idx].move_target(to);}},move_target_back:function(){for(var idx=0;idx<this.points.length;idx++){this.points[idx].move_target_back();}},add_point:function(lat,lng,type,info,highlight){var p=this.mk_point(lat,lng,type);if(info){p.set_interest(true);p.set_info(info);}else{p.set_interest(false);}
81this.points.push_point(p,this.point_group);if(highlight)p.marker_highlight();return p;},add_path_pt:function(lat,lng){var p=this.mk_point(lat,lng);p.set_interest(false);this.path.push_point(p);return p;},add_path_x:function(pthx){this.pthx=pthx;if(this.pthx.lvls=="auto"){this.pthx.lvls="";var idx=0;var len=this.pthx.pts.length;do{var idx_start=idx;do{var b=this.pthx.pts.charCodeAt(idx++)-63;}while(b>=0x20);do{var b=this.pthx.pts.charCodeAt(idx++)-63;}while(b>=0x20);this.pthx.lvls+="B";}while(idx<len);}},gpxadd_wpt:function(wpt){var lat=wpt.getAttribute("lat")*1.0;var lng=wpt.getAttribute("lon")*1.0;return this.add_point(lat,lng,"0",wpt.getElementsByTagName("desc")[0].firstChild.nodeValue);},gpxadd_wpts:function(wpts){for(var idx=0;idx<wpts.length;idx++){this.gpxadd_wpt(wpts[idx]);}},gpxadd_pts:function(pts){var lat=pts.getAttribute("lat")*1.0;var lng=pts.getAttribute("lon")*1.0;this.add_path_pt(lat,lng);},gpxadd_ppts:function(ppts){for(var idx=0;idx<ppts.length;idx++){this.gpxadd_pts(ppts[idx]);}},draw:function(map){var pl=false;if(color_index>=colors.length)
82color_index=0;this.points.render(map);if(!this.pthx){if(this.path&&this.path.length>0)
83pl=new GPolyline(this.path,colors[color_index]);}else{pl=new GPolyline.fromEncoded({color:colors[color_index],points:this.pthx.pts,levels:this.pthx.lvls,weight:10,zoomFactor:32,numLevels:4});}
84try{if(pl)map.addOverlay(pl);}catch(e){}
85color_index++;}});var QuestMap=Class.create({initialize:function(elementName,options){this.treks=[];this.element=$(elementName);this.element.mapObj=this;GMap2=Class.do_extend(GMap2,StatusClass.prototype);this.map=new GMap2($(elementName),options);this.map.setCenter(new GLatLng(37.944197,-122.173461),9);this.map.setMapType(G_SATELLITE_MAP);this.map.qmap=this;this.oheight=this.map.clientHeight;this.owidth=this.map.clientWidth;},size_resize:function(width,height){this.resize_storage={}
86this.resize_storage.hidden=[];var body=document.getElementsByTagName("body")[0];var nodes=body.childNodes;for(var idx=0;idx<nodes.length;idx++){var focus=nodes[idx];if(focus.nodeType==1&&focus.style.display!='none'&&focus!=this.element){this.resize_storage.hidden.push([focus,focus.style.display]);focus.style.display='none';}}
87this.resize_storage.map_parent=this.element.parentNode;this.resize_storage.map_sibling=this.element.nextSibling;this.resize_storage.map_zoom=this.map.getZoom();this.resize_storage.exit=document.createElement("div");this.resize_storage.exit.id="map_xfull";listen(this.resize_storage.exit,"click",function(){that.size_restore();});body.appendChild(this.element);this.element.appendChild(this.resize_storage.exit);this.fullscreen=true;this.resize_storage.restore={position:false,zIndex:false,height:false,width:false,left:false,top:false,bottom:false,right:false};for(k in this.resize_storage.restore){this.resize_storage.restore[k]=this.element.style[k];}
88this.element.style.position="absolute";this.element.style.top="0px";this.element.style.left="0px";this.element.style.zindex="200";var that=this;var resize_perform=function(e){if(e||(!height||!width)){if(document.documentElement.clientHeight&&!window.innerHeight){height=document.documentElement.clientHeight-20;width=document.documentElement.clientWidth-20;}else{height=window.innerHeight-20;width=window.innerWidth-20;}
89that.element.style.width=width+"px";that.element.style.height=height+"px";}
90that.map.checkResize();}
91this.window_target=$('info');var to=$('map');if(this.window_target){this.orig_pos={parent_node:this.window_target.parentNode,sibling_node:this.window_target.previousSibling};to.appendChild(this.window_target);}
92this.resize_storage.dragger=new Draggable($('info_title'),this.window_target);this.resize_storage.resizer=resize_perform;listen(window,"resize",resize_perform);resize_perform();},size_restore:function(){var center=this.map.getCenter();this.map.closeInfoWindow();if(this.fullscreen){this.element.removeChild(this.resize_storage.exit);ignore(window,"resize",this.resize_storage.resizer);for(var idx=0;idx<this.resize_storage.hidden.length;idx++){this.resize_storage.hidden[idx][0].style.display=this.resize_storage.hidden[idx][1];}
93for(k in this.resize_storage.restore){this.element.style[k]=this.resize_storage.restore[k];}
94this.fullscreen=false;for(var idx=0;idx<this.treks.length;idx++){this.treks[idx].move_target_back();}
95this.resize_storage.map_parent.insertBefore(this.element,this.resize_storage.map_sibling);}
96this.map.checkResize();this.map.setCenter(center,this.resize_storage.map_zoom);this.resize_storage={};},map_proper:function(trek){if(trek.points.length==0)
97return;var sw=false;var nw=false;var points=trek.points;if(points.length==1){this.map.setCenter(points[0],10);return;}else{var north=-180;var south=180;var west=180;var east=-180;for(var idx=0;idx<points.length;idx++){var point=points[idx];var lat=point.lat();var lng=point.lng();if(lat<south)south=lat;if(lat>north)north=lat;if(lng<west)west=lng;if(lng>east)east=lng}
98var ne=new GLatLng(north,east);var sw=new GLatLng(south,west);}
99var trek_bounds=new GLatLngBounds(sw,ne);var map_zoom=this.map.getBoundsZoomLevel(trek_bounds);try{var tbcenter=trek_bounds.getCenter();this.map.setCenter(tbcenter,map_zoom);var swp=this.map.fromLatLngToDivPixel(sw);if(swp.x<20||(this.element.clientHeight-swp.y)<20)
100this.map.setCenter(tbcenter,map_zoom-1);}catch(e){}},redraw_treks:function(){this.map.clearOverlays();for(var idx=0;idx<this.treks.length;idx++)
101this.treks[idx].draw(this.map);},set_mode:BlankFunction,load_ixsv2:function(def){this.treks=[];this.map.clearOverlays();var point_count=0;for(var idx=1;idx<def.length;idx++){if(!def[idx].points||def[idx].points.length==0){console.log("Couldn't find any defined trek points");return 0;}
102var trekobj=new QuestTrek2(def[idx].points,def[idx].path,def[idx].more,def[idx].options);point_count+=trekobj.point_count;this.treks.push(trekobj);}
103this.redraw_treks();if(this.treks.length>0){this.treks[0].center(this.map);for(idx=0;idx<this.treks.length;idx++){this.treks[idx].activate(this.map);}}
104return point_count;},filter:function(type){for(var idx=0;idx<this.treks.length;idx++){this.treks[idx].filter(type);}},load_ixs:function(def){var treksrc,trekobj,pntsrc,idx,idx_pnt,p;var COUNT_POINTS=0;var COUNT_TREKS=def.treks.length;if(def.treks){for(idx=0;idx<def.treks.length;idx++){treksrc=def.treks[idx];trekobj=new QuestTrek({src:treksrc,target:$('info'),point_group:treksrc.point_group||def.point_group,rsrc_group:treksrc.rsrc_group||def.rsrc_group});if(!treksrc.pth_x){for(idx_pnt=0;idx_pnt<treksrc.pth.length;idx_pnt++){pntsrc=treksrc.pth[idx_pnt];trekobj.add_path_pt(pntsrc.lat,pntsrc.lng);}}else{trekobj.add_path_x(treksrc.pth_x);}
105for(idx_pnt=0;idx_pnt<treksrc.pts.length;idx_pnt++){COUNT_POINTS++;pntsrc=treksrc.pts[idx_pnt];if(TYPES[pntsrc.type])
106pntsrc.type=TYPES[pntsrc.type];p=trekobj.add_point(pntsrc.lat,pntsrc.lng,pntsrc.type,pntsrc.highlight);if(pntsrc.resources){p.resources=pntsrc.resources;}}
107trekobj.set_resources(treksrc.rsrcs);this.treks.push(trekobj);}}
108if(def.pts){treksrc=def;trekobj=new QuestTrek({src:treksrc,target:$('info'),point_group:treksrc.point_group,rsrc_group:treksrc.rsrc_group});for(idx_pnt=0;idx_pnt<treksrc.pts.length;idx_pnt++){pntsrc=treksrc.pts[idx_pnt];if(TYPES[pntsrc.type])
109pntsrc.type=TYPES[pntsrc.type];p=trekobj.add_point(pntsrc.lat,pntsrc.lng,pntsrc.type,pntsrc.highlight);if(pntsrc.resources){p.resources=pntsrc.resources;}}
110trekobj.set_resources(treksrc.rsrcs);this.treks.push(trekobj);}
111this.redraw_treks();this.map_proper(this.treks[0]);},load_gpx:function(src){var trek=new QuestTrek({src:treksrc,target:$('info')});var that=this;var ro=GXmlHttp.create();ro.onreadystatechange=function(){if(ro.readyState==4){var gpx=GXml.parse(ro.responseText);var root_gpx=gpx.getElementsByTagName("gpx")[0];var trail=root_gpx.getElementsByTagName("trk")[0].getElementsByTagName("trkpt");trek.gpxadd_ppts(trail);trek.gpxadd_wpts(root_gpx.getElementsByTagName("rtept"));that.treks.push(trek);that.redraw_treks();that.map_proper(trek);}}
112ro.open("GET",src,true);ro.send("");}});QuestMap=Class.do_extend(QuestMap,StatusClass.prototype);var MapInit=StatusClass.create({initialize:function(ixs,options){if(GBrowserIsCompatible()){if((!ixs.treks||ixs.treks.length==0)&&ixs.pts.length==0){console.error("Your IXS structure contains no data!");return;}
113var qmap=new QuestMap("map",{disableDragging:true});qmap.set_hook("map_proper",false,function(){this.treks[0].points[0].marker_click();});load_queue=[];for(option in options){var value=options[option];var camelcase=(option.substr(0,1).toUpperCase()+


Write the code in $(document).ready(function(){ });

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜