Skip to content

Instantly share code, notes, and snippets.

@adilkurniaramdan
Created December 16, 2014 15:14
Show Gist options
  • Save adilkurniaramdan/f6c395f218b561a2e3a7 to your computer and use it in GitHub Desktop.
Save adilkurniaramdan/f6c395f218b561a2e3a7 to your computer and use it in GitHub Desktop.
angular-google-map piece of code
angular.extend $scope,
rad:150
circles: []
markers: []
clickedMarker:
id: 0
title: ""
map:
control: {}
center:
latitude: -6.908659
longitude: 107.611163
zoom: 17
dragging: false
bounds: {}
markers: []
events:
click: (mapModel, eventName, originalEventArgs) ->
$timeout ->
e = originalEventArgs[0]
lat = e.latLng.lat()
lon = e.latLng.lng()
$scope.clickedMarker =
id: 0
title: "You clicked here " + "lat: " + lat + " lon: " + lon
latitude: lat
longitude: lon
console.log "You clicked here " + "lat: " + lat + " lon: " + lon
$scope.circles = []
console.log $scope.rad
$scope.circles.push
id: 1
center:
latitude: lat
longitude: lon
radius: +$scope.rad
stroke:
color: "#08B21F"
weight: 2
opacity: 1
fill:
color: "#08B21F"
opacity: 0.2
geodesic: true # optional: defaults to false
$scope.markers = []
$http.post '/api/algorithms/nearestsplace',
lat: $scope.clickedMarker.latitude
lon: $scope.clickedMarker.longitude
radius: +$scope.rad
.success (data) ->
id = 0
$scope.places = data
$scope.places.forEach (v)->
v.onClick = ->
v.show = true
console.log "Clicked!"
v.id = id
v.icon = 'assets/images/icon/parking_bicycle-2.png'
v.latitude = v.loc.coordinates[1]
v.longitude = v.loc.coordinates[0]
arg1 = $scope.clickedMarker.latitude
arg2 = $scope.clickedMarker.longitude
arg3 = v.latitude
arg4 = v.longitude
v.distance = CalculateDistance arg1, arg2, arg3, arg4
d = NearestPlaceService arg1, arg2, arg3, arg4, 'K'
radius = $scope.rad / 1000
$scope.markers.push(v) if radius > d
id++
,3000
# $scope.$apply()
idle: (map) ->
bounds = map.getBounds()
ne = bounds.getNorthEast() # LatLng of the north-east corner
#console.log("ne bounds " + ne.lat() + ", " + ne.lng());
sw = bounds.getSouthWest() # LatLng of the south-west corder
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment