MCPcopy Create free account
hub / github.com/RocketMap/RocketMap / createMyLocationButton

Function createMyLocationButton

static/js/map.js:1110–1149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1108}
1109
1110function createMyLocationButton () {
1111 var locationContainer = document.createElement('div')
1112
1113 var locationButton = document.createElement('button')
1114 locationButton.style.backgroundColor = '#fff'
1115 locationButton.style.border = 'none'
1116 locationButton.style.outline = 'none'
1117 locationButton.style.width = '28px'
1118 locationButton.style.height = '28px'
1119 locationButton.style.borderRadius = '2px'
1120 locationButton.style.boxShadow = '0 1px 4px rgba(0,0,0,0.3)'
1121 locationButton.style.cursor = 'pointer'
1122 locationButton.style.marginRight = '10px'
1123 locationButton.style.padding = '0px'
1124 locationButton.title = 'My Location'
1125 locationContainer.appendChild(locationButton)
1126
1127 var locationIcon = document.createElement('div')
1128 locationIcon.style.margin = '5px'
1129 locationIcon.style.width = '18px'
1130 locationIcon.style.height = '18px'
1131 locationIcon.style.backgroundImage = 'url(static/mylocation-sprite-1x.png)'
1132 locationIcon.style.backgroundSize = '180px 18px'
1133 locationIcon.style.backgroundPosition = '0px 0px'
1134 locationIcon.style.backgroundRepeat = 'no-repeat'
1135 locationIcon.id = 'current-location'
1136 locationButton.appendChild(locationIcon)
1137
1138 locationButton.addEventListener('click', function () {
1139 centerMapOnLocation()
1140 })
1141
1142 locationContainer.index = 1
1143 map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(locationContainer)
1144
1145 google.maps.event.addListener(map, 'dragend', function () {
1146 var currentLocation = document.getElementById('current-location')
1147 currentLocation.style.backgroundPosition = '0px 0px'
1148 })
1149}
1150
1151function centerMapOnLocation () {
1152 var currentLocation = document.getElementById('current-location')

Callers 1

initMapFunction · 0.85

Calls 1

centerMapOnLocationFunction · 0.85

Tested by

no test coverage detected