Hi Everyone,<div><br></div><div>I apologize in advance for what I assume is a pretty trivial error. I've been trying to implement the geolocation example on my local system, but I get an error "ol.control.geolocate is not a constructor" in Firebug, and uncaught typeerror: undefined is not a function in chrome. I've tried this both with linking the OL script to the live api url, as well as to a local copy of OL 2.10. I repost the code below, but I just copied it from the live example and got this error.</div>
<div>Thanks in advance!</div><div><br></div><div><div>var style = {</div><div> fillColor: '#000',</div><div> fillOpacity: 0.1,</div><div> strokeWidth: 0</div><div>};</div><div><br></div><div>var map = new OpenLayers.Map('map');</div>
<div>var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");</div><div>var vector = new OpenLayers.Layer.Vector('vector');</div><div>map.addLayers([layer, vector]);</div><div><br></div><div>map.setCenter(</div>
<div> new OpenLayers.LonLat(-71.147, 42.472).transform(</div><div> new OpenLayers.Projection("EPSG:4326"),</div><div> map.getProjectionObject()</div><div> ), 12</div><div>);</div><div><br></div>
<div>var pulsate = function(feature) {</div><div> var point = feature.geometry.getCentroid(),</div><div> bounds = feature.geometry.getBounds(),</div><div> radius = Math.abs((bounds.right - bounds.left)/2),</div>
<div> count = 0,</div><div> grow = 'up';</div><div><br></div><div> var resize = function(){</div><div> if (count>16) {</div><div> clearInterval(window.resizeInterval);</div><div>
}</div><div> var interval = radius * 0.03;</div><div> var ratio = interval/radius;</div><div> switch(count) {</div><div> case 4:</div><div> case 12:</div><div> grow = 'down'; break;</div>
<div> case 8:</div><div> grow = 'up'; break;</div><div> }</div><div> if (grow!=='up') {</div><div> ratio = - Math.abs(ratio);</div><div> }</div><div>
feature.geometry.resize(1+ratio, point);</div><div> vector.drawFeature(feature);</div><div> count++;</div><div> };</div><div> window.resizeInterval = window.setInterval(resize, 50, point, radius);</div>
<div>};</div><div><br></div><div>var geolocate = new OpenLayers.Control.Geolocate({</div><div> geolocationOptions: {</div><div> enableHighAccuracy: false,</div><div> maximumAge: 0,</div><div> timeout: 7000</div>
<div> }</div><div>});</div><div>map.addControl(geolocate);</div><div>geolocate.events.register("locationupdated",this,function(e) {</div><div> vector.removeAllFeatures();</div><div> var circle = new OpenLayers.Feature.Vector(</div>
<div> OpenLayers.Geometry.Polygon.createRegularPolygon(</div><div> new OpenLayers.Geometry.Point(e.point.x, e.point.y),</div><div> e.position.coords.accuracy/2,</div><div> 40,</div>
<div> 0</div><div> ),</div><div> {},</div><div> style</div><div> );</div><div> vector.addFeatures([</div><div> new OpenLayers.Feature.Vector(</div><div> e.point,</div>
<div> {},</div><div> {</div><div> graphicName: 'cross',</div><div> strokeColor: '#f00',</div><div> strokeWidth: 2,</div><div> fillOpacity: 0,</div>
<div> pointRadius: 10</div><div> }</div><div> ),</div><div> circle</div><div> ]);</div><div> map.zoomToExtent(vector.getDataExtent());</div><div> pulsate(circle);</div><div>
});</div><div>geolocate.events.register("locationfailed",this,function() {</div><div> OpenLayers.Console.log('Location detection failed');</div><div>});</div><div><br></div><div>$('locate').onclick = function() {</div>
<div> vector.removeAllFeatures();</div><div> geolocate.deactivate();</div><div> $('track').checked = false;</div><div> geolocate.watch = false;</div><div> geolocate.activate();</div><div>};</div><div>
$('track').onclick = function() {</div><div> vector.removeAllFeatures();</div><div> geolocate.deactivate();</div><div> if (this.checked) {</div><div> geolocate.watch = true;</div><div> geolocate.activate();</div>
<div> }</div><div>};</div><div>$('track').checked = false;</div>-- <br><br><div>Dept. of Anthropology</div><div>Washington University in St. Louis</div><div>Campus Box 1114</div><div>St. Louis, MO, 63130</div><div>
(917) 370-3489</div><div><a href="mailto:nefremov@artsci.wustl.edu" target="_blank">nefremov@wustl.edu</a><br></div><br>
</div>