Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Auth tweaking

  • Loading branch information...
commit 4ee9145280c6fa78492b748e3a8af58bcf2fff4e 1 parent 55e701e
iplk authored
160 web/assets/cslib/Mapview.coffee
... ... @@ -0,0 +1,160 @@
  1 +# Set up the Google map
  2 +
  3 +overlaysOnMap = []
  4 +
  5 +RemoveFromMap = () ->
  6 + for o in overlaysOnMap
  7 + o.setMap null
  8 +
  9 + overlaysOnMap = []
  10 +
  11 +SetupMap = () ->
  12 +
  13 + # Map set up
  14 + mapCenter = new google.maps.LatLng -41.288889, 174.777222
  15 +
  16 +
  17 + style = `
  18 + [
  19 + {
  20 + "stylers": [
  21 + { "visibility": "off" }
  22 + ]
  23 + },{
  24 + "featureType": "water",
  25 + "elementType": "geometry.fill",
  26 + "stylers": [
  27 + { "visibility": "on" },
  28 + { "lightness": 1 },
  29 + { "color": "#19232F" }
  30 + ]
  31 + },{
  32 + "featureType": "landscape",
  33 + "elementType": "geometry.fill",
  34 + "stylers": [
  35 + { "visibility": "on" },
  36 + { "color": "#B4B577" }
  37 + ]
  38 + },{
  39 + "featureType": "poi",
  40 + "elementType": "geometry",
  41 + "stylers": [
  42 + { "visibility": "on" },
  43 + { "color": "#C8DE9B" }
  44 + ]
  45 + }
  46 + ]`
  47 +
  48 + mapOptions = {
  49 + styles: style
  50 + zoom: 9,
  51 + center: mapCenter,
  52 + mapTypeId: google.maps.MapTypeId.ROADMAP,
  53 + disableDefaultUI: true
  54 + }
  55 +
  56 + elem = document.getElementById 'map_canvas'
  57 +
  58 + new google.maps.Map elem, mapOptions
  59 +
  60 +
  61 +googleMap = SetupMap()
  62 +google.maps.event.addDomListener(window, "load", googleMap);
  63 +
  64 +# Fix the height of the map, twitter bootstrap fucks it up, it probbly fucks up some other map things aswell
  65 +mapCanvas = $ "#map_canvas"
  66 +mapCanvas.css {height: "100%" }
  67 +# mapCanvasHeight = mapCanvas.css "height"
  68 +# mapCanvas.css {height: "#{mapCanvasHeight - 50}px"}
  69 +
  70 +# Zoom listner
  71 +# google.maps.event.addListener googleMap, "zoom_changed", ->
  72 +# console.log "Zoom #{googleMap.getZoom()} "
  73 +size = 0.05
  74 +current = 0;
  75 +range = 16;
  76 +
  77 +createOverlay = (incident) ->
  78 +
  79 + geo = incident.geolocation
  80 +
  81 + lat = new google.maps.LatLng geo.lat - size * 0.125, geo.long - size * 0.25
  82 + lng = new google.maps.LatLng geo.lat + size * 0.125, geo.long + size * 0.25
  83 +
  84 + imageBounds = new google.maps.LatLngBounds lat, lng
  85 + overlay = new google.maps.GroundOverlay "#{incident.thumbnail_url}", imageBounds
  86 +
  87 + google.maps.event.addListener overlay, 'click', () =>
  88 + window.CreateIncidentModal incident.id
  89 +
  90 + overlay.setMap googleMap
  91 + overlaysOnMap.push overlay
  92 +
  93 +onSuccess = (data) ->
  94 + for incident in data.incidents
  95 + console.log "creating incident #{current}"
  96 + current++
  97 + createOverlay incident
  98 +
  99 +onFail = (data) ->
  100 + console.log "Rest Call failed"
  101 +
  102 +window.RWCall onSuccess, onFail, {}, "approved", "/start=#{current}/number=#{range}", "GET"
  103 +
  104 +
  105 +# Controls
  106 +nextButton = $ "#nextBtn"
  107 +prevButton = $ "#prevBtn"
  108 +d16Button = $ "#d16"
  109 +d32Button = $ "#d32"
  110 +d64Button = $ "#d64"
  111 +d128Button = $ "#d128"
  112 +d256Button = $ "#d256"
  113 +
  114 +nextButton.click ->
  115 + RemoveFromMap()
  116 + console.log "Clicked Next"
  117 + window.RWCall onSuccess, onFail, {}, "approved", "/start=#{current}/number=#{range}", "GET"
  118 +
  119 +prevButton.click ->
  120 + RemoveFromMap()
  121 + console.log "Clicked Prev"
  122 + current = if current - range > 0 then current - range else 0;
  123 + window.RWCall onSuccess, onFail, {}, "approved", "/start=#{current}/number=#{range}", "GET"
  124 +
  125 +changeRange = (newRange) ->
  126 + RemoveFromMap()
  127 + current = if current - range > 0 then current - range else 0;
  128 + range = newRange;
  129 + window.RWCall onSuccess, onFail, {}, "approved", "/start=#{current}/number=#{range}", "GET"
  130 +
  131 +d16Button.click -> changeRange 16
  132 +d32Button.click -> changeRange 32
  133 +d64Button.click -> changeRange 64
  134 +d128Button.click -> changeRange 128
  135 +d256Button.click -> changeRange 256
  136 +
  137 +###
  138 +for incident in incidentList.Incidents
  139 +
  140 + newarkLat = new google.maps.LatLng incident.Lat - size, incident.Lng - size * 2
  141 + newarkLng = new google.maps.LatLng incident.Lat + size, incident.Lng + size * 2
  142 +
  143 + borderCoordinates = [
  144 + new google.maps.LatLng incident.Lat - size, incident.Lng - size * 2
  145 + new google.maps.LatLng incident.Lat - size, incident.Lng + size * 2
  146 + new google.maps.LatLng incident.Lat + size, incident.Lng + size * 2
  147 + new google.maps.LatLng incident.Lat + size, incident.Lng - size * 2
  148 + new google.maps.LatLng incident.Lat - size, incident.Lng - size * 2
  149 + ]
  150 +
  151 + border = new google.maps.Polyline {
  152 + path: borderCoordinates,
  153 + strokeColor: "000000",
  154 + strokeOpacity: 1,
  155 + strokeWeight: 1
  156 + }
  157 +
  158 +
  159 + border.setMap googleMap
  160 +###
3  web/assets/cslib/Users.coffee
@@ -45,7 +45,8 @@ loginButton.click ->
45 45 ###
46 46
47 47 # Check for the admin cookie and set the status...
48   -setLogInControl()
  48 +$ ->
  49 + setLogInControl()
49 50
50 51
51 52
4 web/assets/js/Users.js
@@ -69,6 +69,8 @@
69 69 setLogInControl()
70 70 */
71 71
72   - setLogInControl();
  72 + $(function() {
  73 + return setLogInControl();
  74 + });
73 75
74 76 }).call(this);

0 comments on commit 4ee9145

Please sign in to comment.
Something went wrong with that request. Please try again.