Hi all,<div><br></div><div>I&#39;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&#39;ve gotten the parts of the script to work, but I&#39;m not sure what&#39;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 &quot;<span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, &#39;Lucida Console&#39;, 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 &#39;getCode&#39;&quot;</span></div>
<div><span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Consolas, &#39;Lucida Console&#39;, 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, &#39;Lucida Console&#39;, 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, &#39;Lucida Console&#39;, 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, &#39;Lucida Console&#39;, 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&#39;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(&quot;Markers&quot;);</div><div>var map = new OpenLayers.Map(&#39;map&#39;);</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(&quot;EPSG:4326&quot;),map.getProjectionObject()),12);</div>
<div>}</div><div><br></div><div>jQuery(window).ready(function(){jQuery(&quot;#btnInit&quot;).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(&#39;visitor&#39;,norm_yql_resp);</div><div>}</div><div>}</div><div><br></div><div><br></div><div>function showMap(position)</div><div>{</div><div>//alert(&#39;Lat: &#39; + position.coords.latitude + &#39; &#39; + &#39;Lon: &#39; + position.coords.longitude + &#39; &#39; + &#39;Acc: &#39; + position.coords.accuracy);</div>
<div>var lonlat = new OpenLayers.LonLat(position.coords.longitude,position.coords.latitude).transform(new OpenLayers.Projection(&quot;EPSG:4326&quot;), 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>&lt;/script&gt;</div><div>&lt;/body&gt;</div><div>&lt;/html&gt;</div></span></font></div>