Skip to content

Commit

Permalink
Revert "Merge pull request #160 from l-hedgehog/g-maps-api-v3"
Browse files Browse the repository at this point in the history
This reverts commit f83d637, reversing
changes made to 0e33165.
  • Loading branch information
rik committed Jul 3, 2012
1 parent 14e6beb commit 274ed07
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/firefox/templates/firefox/geolocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ <h4 class="expander-header">How do I turn off Location-Aware Browsing permanentl

</div> <!-- end #main -->

<script src="//maps.googleapis.com/maps/api/js?sensor=true&amp;key={{ gmap_api_key }}"></script>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key={{ gmap_api_key }}"></script>

{% endblock %}
57 changes: 35 additions & 22 deletions media/js/geolocation-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,52 @@ var overlay = null;

var geodemo = {
initialize: function() {
map = new google.maps.Map(document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.41, -122.08),
zoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.41, -122.08), 1);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
},

getCircleOverlay: function(lat, lon, err) {
// math lifted from maps.forum.nu. you want map examples, go there.
with (Math) {
var points = Array();
var d = err/6378800;// accuracy / meters of Earth radius = radians
var lat1 = (PI/180)* lat; // radians
var lng1 = (PI/180)* lon; // radians

for (var a = 0 ; a < 361 ; a+=10 ) {
var tc = (PI/180)*a;
var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc));
var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y));
var x = ((lng1-dlng+PI) % (2*PI)) - PI ; // MOD function
var point = new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/PI)));
points.push(point);
}
}
return new GPolygon(points,'#0000ff',1,1,'#0000ff',0.2)
},

zoomLevel: function(a, step) {
step++;
map.setCenter(new GLatLng(a.coords.latitude, a.coords.longitude), step);
if (step > 14) return;
window.setTimeout(function() { geodemo.zoomLevel(a, step) }, 250);
},

aaa: function(a) {
var center = new google.maps.LatLng(a.coords.latitude, a.coords.longitude);
$('#locateButton').siblings('img').hide();
var zoomLevel = 14;

if (a.coords.accuracy > 500)
zoomLevel = 10;

map.setCenter(center);
map.setZoom(zoomLevel);
map.setCenter(new GLatLng(a.coords.latitude, a.coords.longitude), zoomLevel);

if (overlay) {
overlay.setMap(null);
overlay = null;
}
if (overlay) map.removerOverlay(overlay);

overlay = new google.maps.Circle({
center: center,
radius: a.coords.accuracy,
fillColor: '#0000ff',
fillOpacity: 0.2,
strokeColor: '#0000ff',
strokeOpacity: 1,
strokeWeight: 1
});
overlay.setMap(map);
overlay = geodemo.getCircleOverlay(a.coords.latitude, a.coords.longitude, a.coords.accuracy);
map.addOverlay(overlay);
},

handleError: function(a) {
Expand Down

0 comments on commit 274ed07

Please sign in to comment.