Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. Error in event handler for (unknown): TypeError: Cannot read property 'state' of null
  2. at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:43:13)
  3. at messageListener (extensions::messaging:343:9)
  4. at Function.target.(anonymous function) (extensions::SafeBuiltins:19:14)
  5. at Event.dispatchToListener (extensions::event_bindings:394:22)
  6. at Event.dispatch_ (extensions::event_bindings:378:27)
  7. at Event.dispatch (extensions::event_bindings:400:17)
  8. at dispatchOnMessage (extensions::messaging:307:22) extensions::event_bindings:382
  9. ZERO_RESULTS TestAPI4?sfdc.tabName=01ri0000000x2nx:70
  10. [] TestAPI4?sfdc.tabName=01ri0000000x2nx:71
  11.  
  12. <script>
  13. function initialize() {
  14. var lat, lon;
  15. // If we can, get the position of the user via device geolocation
  16. if (navigator.geolocation) {
  17. navigator.geolocation.getCurrentPosition(function (position) {
  18. lat = position.coords.latitude;
  19. lon = position.coords.longitude;
  20. mapNew(lat, lon)
  21. });
  22. } else {
  23. alert('The Browser Does Not Support GEO');
  24. }
  25. mapNew()
  26. }
  27.  
  28.  
  29. function mapNew(lat, lon) {
  30. var CurrentLocation = new google.maps.LatLng(lat, lon)
  31.  
  32. var mapProp = {
  33. center: CurrentLocation,
  34. zoom: 15,
  35. mapTypeId: google.maps.MapTypeId.ROADMAP
  36. };
  37.  
  38. var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
  39.  
  40. //Marker // Current Location // Working
  41. var marker = new google.maps.Marker({
  42. position: CurrentLocation,
  43. });
  44.  
  45. //InfoWindow Current Location // You Are Here // Working
  46. var infowindow = new google.maps.InfoWindow({
  47. content: 'Your Location'
  48. });
  49. infowindow.open(map, marker);
  50. marker.setMap(map);
  51.  
  52. // Keep track of the map boundary that holds all markers
  53. var mapBoundary = new google.maps.LatLngBounds();
  54. mapBoundary.extend(CurrentLocation);
  55.  
  56. getNearMe(CurrentLocation, map);
  57.  
  58. function getNearMe(CurrentLocation, map) {
  59.  
  60. var request = {
  61. location: CurrentLocation,
  62. radius: '5000',
  63. keyword: ['Reece Plumbing']
  64. };
  65.  
  66. var service_places = new google.maps.places.PlacesService(map);
  67. service_places.nearbySearch(request, function (response, status) {
  68. console.log(status);
  69. console.log(response);
  70.  
  71. // Set markers on the map
  72. var reece;
  73. for (var i = 0; i < response.length; i++) {
  74. reece = response[i];
  75. console.log(response[i]);
  76. setupMarker();
  77. }
  78.  
  79. // Resize map to neatly fit all of the markers
  80. map.fitBounds(mapBoundary);
  81.  
  82.  
  83. function setupMarker() {
  84.  
  85. var marker = new google.maps.Marker({
  86. map: map,
  87. position: reece.geometry.location,
  88. icon: 'https://maps.google.com/mapfiles/ms/micons/green.png'
  89. });
  90.  
  91. var reeceDetails = reece.name + '<br/>' + reece.vicinity + '<br/>';
  92.  
  93. // Create the callout that will pop up on the marker
  94. var infowindow = new google.maps.InfoWindow({
  95. content: reeceDetails
  96. });
  97. mapBoundary.extend(marker.getPosition());
  98.  
  99. // Add the action to open up the panel when it's marker is clicked
  100. google.maps.event.addListener(marker, 'click', function () {
  101. infowindow.open(map, marker);
  102. });
  103. }
  104. });
  105. }
  106. }
  107.  
  108. google.maps.event.addDomListener(window, 'load', initialize);
  109.  
  110. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement