Show current location not working using leaflet

Current location not shows in MAP,

function showPosition(position) {
// alert(“test1234”)
//alert(position.coords.latitude)
//alert(position.coords.longitude)

       // alert("position")
       marker = new L.Marker([position.coords.latitude, position.coords.longitude], { bounceOnAdd: false }).addTo(map);
       var popup = L.popup()
         alert("popup")
      .setLatLng([position.coords.latitude, position.coords.longitude])
      .setContent('You are here!')
      .openOn(map);         
    }

Hi @thangae,

Please take note that: there’s will be a security reason for tracking location in Web Application Development on non-SSL aka http (running localhost).

Those are the example code from our docs.onemap.sg/maps however you have to implement your own current location coding.

getLocation() gives the current location which is not fully implemented in the example due to above issue.
showPosition(position) means you have sending the lat,lng to the map to update the marker.

You can try to see my sample code here: https://codepen.io/kyroskoh/pen/BaBgVVV