Created
June 23, 2014 05:04
-
-
Save adamrights/b3826d3bce8cf88f3c0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
`// noprotect` | |
rndAddToLatLon = -> | |
Math.floor (((if Math.random() < 0.5 then -1 else 1)) * 2) + 1 | |
console.log "ANGULAR DEFINED" if angular | |
angular.module("myApp",["google-maps"]) | |
.controller "MyCtrl", ($scope, $timeout, $log, $http) -> | |
$log.info "IN MyCtrl!!" | |
# Enable the new Google Maps visuals until it gets enabled by default. | |
# See http://googlegeodevelopers.blogspot.ca/2013/05/a-fresh-new-look-for-maps-api-for-all.html | |
google.maps.visualRefresh = true | |
versionUrl = (if window.location.host is "rawgithub.com" then "http://rawgithub.com/nlaplante/angular-google-maps/master/package.json" else "/package.json") | |
$http.get(versionUrl).success (data) -> | |
console.error "no version object found!!" unless data | |
$scope.version = data.version | |
return | |
angular.extend $scope, | |
map: | |
control: {} | |
center: | |
latitude: 45 | |
longitude: -74 | |
marker: | |
latitude: 45 | |
longitude: -74 | |
options: | |
visible: false | |
marker2: | |
latitude: 45.2 | |
longitude: -74.5 | |
# dragging:false, //appears to be required | |
zoom: 7 | |
options: | |
disableDefaultUI: false | |
panControl: true | |
navigationControl: true | |
scrollwheel: true | |
scaleControl: false | |
refresh: -> | |
$scope.map.control.refresh origCenter | |
return | |
markers3: [ | |
{ | |
coords: | |
latitude: 52.2 | |
longitude: -80.5 | |
icon: "http://files.softicons.com/download/web-icons/vista-map-markers-icons-by-icons-land/png/48x48/MapMarker_Marker_Outside_Azure.png" | |
show: false | |
} | |
{ | |
coords: | |
latitude: 45.2 | |
longitude: -74.5 | |
} | |
{ | |
coords: | |
latitude: 46.2 | |
longitude: -75.5 | |
} | |
] | |
origCenter = | |
latitude: $scope.map.center.latitude | |
longitude: $scope.map.center.longitude | |
$timeout => | |
bounds = new google.maps.LatLngBounds() | |
$scope.map.markers3.forEach (m)-> | |
geoCode = new google.maps.LatLng(m.coords.latitude, m.coords.longitude) | |
bounds.extend(geoCode) | |
$scope.map.control.getGMap().fitBounds(bounds) | |
, 500 | |
return |
This file contains hidden or 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
body { | |
font-family: 'Open Sans', sans-serif; | |
} | |
.angular-google-map-container { | |
width: 100%; | |
height: 600px; | |
} | |
/* fix for Twitter Bootstrap handling of responsive images */ | |
.angular-google-map img { | |
max-width: inherit; | |
} | |
.angular-google-map { | |
top: 80px; | |
} | |
.shrink { | |
font-size: 8; | |
} | |
.true:hover { | |
background-color: lightgreen; | |
} | |
.false:hover { | |
background-color: lightpink; | |
} | |
.marker-labels { | |
color: red; | |
background-color: white; | |
font-family: "Lucida Grande", "Arial", sans-serif; | |
font-size: 10px; | |
font-weight: bold; | |
text-align: center; | |
width: 40px; | |
border: 1px solid black; | |
white-space: nowrap; | |
} | |
/* uncomment this if you are using the <google-map> element instead of a div | |
.angular-google-map { | |
display: block; | |
}*/ | |
.custom-info-window{ | |
background: rgba(0,0,0,0.5); | |
color: white; | |
padding: 20px; | |
/*border: 1px solid white;*/ | |
box-shadow: 3px 3px 10px rgba(0,0,0,0.5); | |
border-radius: 5px; | |
width: 200px; | |
margin-top: 15px; | |
margin-left: -130px; | |
} | |
.custom-info-window a{ | |
color: white; | |
text-decoration: underline; | |
} | |
.custom-info-window:after | |
{ | |
content: ''; | |
position: absolute; | |
border-style: solid; | |
border-width: 0 15px 15px; | |
border-color: rgba(0,0,0,0.5) transparent; | |
display: block; | |
width: 0; | |
z-index: 1; | |
top: -15px; | |
left: 118px; | |
} | |
This file contains hidden or 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
<!DOCTYPE html> | |
<html ng-app="myApp"> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<script src="http://maps.googleapis.com/maps/api/js?libraries=weather,visualization&sensor=false&language=en&v=3.14"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore.js" type="text/javascript"></script> | |
<script src="http://rawgithub.com/nlaplante/angular-google-maps/master/dist/angular-google-maps.js"></script> | |
</head> | |
<body ng-controller="MyCtrl" > | |
<google-map center="map.center" | |
zoom="map.zoom" | |
options="map.options" | |
dragging="map.dragging" | |
draggable="true" | |
control="map.control" | |
> | |
<marker ng-repeat="m in map.markers3" coords="m.coords" icon="m.icon"></marker> | |
</google-map> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment