Hi all,<div><br></div><div>I've hacked together a geolocation script using the OpenLayers demo, a tutorial on Mobile Tutorials <a href="http://mobile.tutsplus.com/tutorials/mobile-web-apps/html5-geolocation/">http://mobile.tutsplus.com/tutorials/mobile-web-apps/html5-geolocation/</a>, and a couple of other OL-Geolocation demos out there. Independently, I've gotten the parts of the script to work, but I'm not sure what's happening here when bring them all togehter and use jquery for my button firing. </div>
<div><br></div><div>The script calls the initGIS function onLoad loading a simple map set to a lonlat. The button then fires the geolocation script, which uses modernizr to check for geoloc support, provides error checking and olderbrowser support via YQL (maybe I should use the MIT-license geo.js? suggestions). The script was breaking on adding the markers, but I realized that I had to declare some of the variables as globals. The issue now is a rather opaque error in the OL code saying "<span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; line-height: 12px; white-space: pre-wrap; ">Uncaught TypeError: Object function (){var a=null;if(this.baseLayer!=null)a=this.baseLayer.projection;return a} has no method 'getCode'"</span></div>
<div><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; line-height: 12px; white-space: pre-wrap; "><br></span></div><div><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap; "><font class="Apple-style-span" face="arial, helvetica, sans-serif">Firefox returns the following error.</font></span></div>
<div><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; line-height: 12px; white-space: pre-wrap; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; line-height: 12px; white-space: pre-wrap; ">attempt to run compile-and-go script on a cleared scope</span></div>
<div><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, 'Lucida Console', monospace; font-size: 12px; line-height: 12px; white-space: pre-wrap; "><br></span></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap; ">The chrome error says the script breaks at OL line 311, while FF says that the script is breaking at OL 256. This is above my programming experience, and I'm not sure how to resolve this error.</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap; "><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap; ">code is as follows with the error checking functions cut off the end of it.</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap; "><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px; line-height: 12px; white-space: pre-wrap;"><div>
var markers = new OpenLayers.Layer.Markers("Markers");</div><div>var map = new OpenLayers.Map('map');</div><div>function initGIS(){</div><div>map.addControl(new OpenLayers.Control.LayerSwitcher());</div>
<div>var mapnik = new OpenLayers.Layer.OSM();</div><div>map.addLayer(mapnik);<span class="Apple-tab-span" style="white-space:pre">        </span></div><div>map.setCenter(new OpenLayers.LonLat(-90, 38).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),12);</div>
<div>}</div><div><br></div><div>jQuery(window).ready(function(){jQuery("#btnInit").click(getLoc);});</div><div>function getLoc(){</div><div>if (Modernizr.geolocation) {</div><div> navigator.geolocation.getCurrentPosition(showMap,handle_error);</div>
<div>} else {</div><div>yqlgeo.get('visitor',norm_yql_resp);</div><div>}</div><div>}</div><div><br></div><div><br></div><div>function showMap(position)</div><div>{</div><div>//alert('Lat: ' + position.coords.latitude + ' ' + 'Lon: ' + position.coords.longitude + ' ' + 'Acc: ' + position.coords.accuracy);</div>
<div>var lonlat = new OpenLayers.LonLat(position.coords.longitude,position.coords.latitude).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject);</div><div>markers.addMarker(new OpenLayers.Marker(lonlat));</div>
<div>map.setCenter(new OpenLayers.LonLat(lonlat, 12));</div><div>map.addLayer(markers);</div><div>}</div><div>}</div><div></script></div><div></body></div><div></html></div></span></font></div>