Click here to Skip to main content
15,910,083 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionProblem with Geolocation Pin
Member 1463743128-Oct-19 13:50
Member 1463743128-Oct-19 13:50 
This is the first time i've posted on this website, so if i'm doing something wrong just let me know. Anyways, I'm having a problem getting my geolocation to work. I absolutely cannot figure out what the problem is. Without the geolocation bit of code, the default location, markers, and such work fine. Then when I try to add in the geolocation the map won't appear at all and just the button appears.

<pre><div id="map"> </div>     
    <script>
    var map;
    function initMap() {
    var myLatLng = {lat: 41.413118, lng: -82.072537}

     map = new google.maps.Map(document.getElementById('map'), {
      center: myLatLng,
      zoom: 18
     });

     var marker = new google.maps.Marker({
     position: myLatLng,
     map: map,
     title: 'My Location'
     });

     var marker = new google.maps.Marker({
     position: {lat: 41.412726, lng: -82.072047},
     map: map,
     title: 'PS Building',
     label: {text:'PS Building'}
     });

     infoWindow = new google.maps.InfoWindow;

     if (navigator.geolocation) {
     navigator.geolocation.getCurrentPosition(function(position) {
     var pos = {
       lat: position.coords.latitude,
       lng: position.coords.longitude
     };
     var marker = new google.maps.Marker({
      position: pos,
      map: map,
      title: 'Your Location'
     });

     infoWindow.setPosition(pos);
     infoWindow.open(map);
     map.setCenter(pos);
     }, function() {
     handleLocationError(true, infoWindow, map.getCenter());
     });
     } else {
     // Browser doesn't support Geolocation
     handleLocationError(false, infoWindow, map.getCenter());
    }
   }

 function handleLocationError(browserHasGeolocation, infoWindow, pos) {
 infoWindow.setPosition(pos);
 infoWindow.setContent(browserHasGeolocation ?
                      'Error: The Geolocation service failed.' :
                       'Error: Your browser doesn\'t support 
 geolocation.');
 infoWindow.open(map);
 }
 }


  </script>
  <script src="https://maps.googleapis.com/maps/api/js?key= 
  AIzaSyCyO4aFysnjiQ9DO5VSDSJ_DtPd6O9mkDI&callback=initMap"
  async defer></script>

  <form>
  <input type="button" onclick="GetLocation();" value="click"/>
  </form>

AnswerRe: Problem with Geolocation Pin
Nathan Minier29-Oct-19 1:31
professionalNathan Minier29-Oct-19 1:31 
GeneralRe: Problem with Geolocation Pin
Richard Deeming29-Oct-19 2:16
mveRichard Deeming29-Oct-19 2:16 
GeneralRe: Problem with Geolocation Pin
Nathan Minier29-Oct-19 2:46
professionalNathan Minier29-Oct-19 2:46 
AnswerRe: Problem with Geolocation Pin
A_Griffin2-Nov-19 8:00
A_Griffin2-Nov-19 8:00 
QuestionOpening an External URL Page in my Modal Dialog and capture some of the information that's being submitted to the parent React Pin
simpledeveloper23-Oct-19 12:29
simpledeveloper23-Oct-19 12:29 
AnswerRe: Opening an External URL Page in my Modal Dialog and capture some of the information that's being submitted to the parent React Pin
jkirkerx24-Oct-19 12:35
professionaljkirkerx24-Oct-19 12:35 
GeneralRe: Opening an External URL Page in my Modal Dialog and capture some of the information that's being submitted to the parent React Pin
simpledeveloper24-Oct-19 13:23
simpledeveloper24-Oct-19 13:23 
QuestionCan ms blazor be next level of client-side coding Pin
simpledeveloper23-Oct-19 11:42
simpledeveloper23-Oct-19 11:42 
AnswerRe: Can ms blazor be next level of client-side coding Pin
jkirkerx24-Oct-19 12:00
professionaljkirkerx24-Oct-19 12:00 
GeneralRe: Can ms blazor be next level of client-side coding Pin
simpledeveloper24-Oct-19 13:22
simpledeveloper24-Oct-19 13:22 
GeneralRe: Can ms blazor be next level of client-side coding Pin
jkirkerx25-Oct-19 10:53
professionaljkirkerx25-Oct-19 10:53 
AnswerRe: Can ms blazor be next level of client-side coding Pin
Pete O'Hanlon5-Nov-19 0:45
mvePete O'Hanlon5-Nov-19 0:45 
GeneralRe: Can ms blazor be next level of client-side coding Pin
simpledeveloper5-Nov-19 6:09
simpledeveloper5-Nov-19 6:09 
GeneralRe: Can ms blazor be next level of client-side coding Pin
Pete O'Hanlon5-Nov-19 20:40
mvePete O'Hanlon5-Nov-19 20:40 
QuestionOpen base64 encoded pdf file using javascript Pin
Member 1286358021-Oct-19 4:16
Member 1286358021-Oct-19 4:16 
AnswerRe: Open base64 encoded pdf file using javascript Pin
jkirkerx21-Oct-19 12:22
professionaljkirkerx21-Oct-19 12:22 
AnswerRe: Open base64 encoded pdf file using javascript Pin
Richard Deeming22-Oct-19 1:15
mveRichard Deeming22-Oct-19 1:15 
GeneralRe: Open base64 encoded pdf file using javascript Pin
jkirkerx24-Oct-19 12:18
professionaljkirkerx24-Oct-19 12:18 
AnswerRe: Open base64 encoded pdf file using javascript Pin
Parth Munjpara22-Oct-19 23:11
Parth Munjpara22-Oct-19 23:11 
QuestionWant to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
simpledeveloper17-Oct-19 13:27
simpledeveloper17-Oct-19 13:27 
AnswerRe: Want to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
jkirkerx21-Oct-19 12:11
professionaljkirkerx21-Oct-19 12:11 
GeneralRe: Want to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
simpledeveloper21-Oct-19 13:16
simpledeveloper21-Oct-19 13:16 
GeneralRe: Want to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
jkirkerx22-Oct-19 7:21
professionaljkirkerx22-Oct-19 7:21 
GeneralRe: Want to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
simpledeveloper22-Oct-19 8:56
simpledeveloper22-Oct-19 8:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.