Created
November 22, 2010 12:32
-
-
Save kuon/709900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
didCreateLayer:function() { | |
var bl = SG.broadcastLocationsController.get('firstObject'); | |
console.log('createLayer'); | |
if(!bl) return; | |
var redMarker = new google.maps.MarkerImage( | |
static_url('/images/2.png'), | |
new google.maps.Size(20, 20), | |
new google.maps.Point(0, 20) | |
); | |
var orangeMarker = new google.maps.MarkerImage( | |
static_url('/images/2.png'), | |
new google.maps.Size(20, 20), | |
new google.maps.Point(0, 40) | |
); | |
var greenMarker = new google.maps.MarkerImage( | |
static_url('/images/2.png'), | |
new google.maps.Size(20, 20), | |
new google.maps.Point(0, 60) | |
); | |
var center = new google.maps.LatLng(bl.get('lat'), bl.get('lon')); | |
var opts = { | |
zoom: 14, | |
center: center, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(this.get('layer'), opts); | |
var bls = SG.broadcastLocationsController.get('arrangedObjects'); | |
bls.forEach(function (bl) { | |
var ll = new google.maps.LatLng(bl.get('lat'), bl.get('lon')); | |
var marker; | |
switch(bl.get('monitoringStatus')) { | |
case SG.BroadcastLocation.GOOD: | |
marker = greenMarker; | |
break; | |
case SG.BroadcastLocation.WARNING: | |
marker = orangeMarker; | |
break; | |
case SG.BroadcastLocation.FAILURE: | |
default: | |
marker = redMarker; | |
break; | |
} | |
var m = new google.maps.Marker({ | |
position: ll, | |
map: map, | |
icon:marker | |
}); | |
m._bl = bl; | |
google.maps.event.addListener(m, 'click', function() { | |
SG.monitoringPage.showBroadcastLocation(this._bl); | |
}); | |
}); | |
} | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment