Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error in event handler for (unknown): TypeError: Cannot read property 'state' of null
- at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:43:13)
- at messageListener (extensions::messaging:343:9)
- at Function.target.(anonymous function) (extensions::SafeBuiltins:19:14)
- at Event.dispatchToListener (extensions::event_bindings:394:22)
- at Event.dispatch_ (extensions::event_bindings:378:27)
- at Event.dispatch (extensions::event_bindings:400:17)
- at dispatchOnMessage (extensions::messaging:307:22) extensions::event_bindings:382
- ZERO_RESULTS TestAPI4?sfdc.tabName=01ri0000000x2nx:70
- [] TestAPI4?sfdc.tabName=01ri0000000x2nx:71
- <script>
- function initialize() {
- var lat, lon;
- // If we can, get the position of the user via device geolocation
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function (position) {
- lat = position.coords.latitude;
- lon = position.coords.longitude;
- mapNew(lat, lon)
- });
- } else {
- alert('The Browser Does Not Support GEO');
- }
- mapNew()
- }
- function mapNew(lat, lon) {
- var CurrentLocation = new google.maps.LatLng(lat, lon)
- var mapProp = {
- center: CurrentLocation,
- zoom: 15,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
- //Marker // Current Location // Working
- var marker = new google.maps.Marker({
- position: CurrentLocation,
- });
- //InfoWindow Current Location // You Are Here // Working
- var infowindow = new google.maps.InfoWindow({
- content: 'Your Location'
- });
- infowindow.open(map, marker);
- marker.setMap(map);
- // Keep track of the map boundary that holds all markers
- var mapBoundary = new google.maps.LatLngBounds();
- mapBoundary.extend(CurrentLocation);
- getNearMe(CurrentLocation, map);
- function getNearMe(CurrentLocation, map) {
- var request = {
- location: CurrentLocation,
- radius: '5000',
- keyword: ['Reece Plumbing']
- };
- var service_places = new google.maps.places.PlacesService(map);
- service_places.nearbySearch(request, function (response, status) {
- console.log(status);
- console.log(response);
- // Set markers on the map
- var reece;
- for (var i = 0; i < response.length; i++) {
- reece = response[i];
- console.log(response[i]);
- setupMarker();
- }
- // Resize map to neatly fit all of the markers
- map.fitBounds(mapBoundary);
- function setupMarker() {
- var marker = new google.maps.Marker({
- map: map,
- position: reece.geometry.location,
- icon: 'https://maps.google.com/mapfiles/ms/micons/green.png'
- });
- var reeceDetails = reece.name + '<br/>' + reece.vicinity + '<br/>';
- // Create the callout that will pop up on the marker
- var infowindow = new google.maps.InfoWindow({
- content: reeceDetails
- });
- mapBoundary.extend(marker.getPosition());
- // Add the action to open up the panel when it's marker is clicked
- google.maps.event.addListener(marker, 'click', function () {
- infowindow.open(map, marker);
- });
- }
- });
- }
- }
- google.maps.event.addDomListener(window, 'load', initialize);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement