Monday 15 July 2013

jquery - TypeError: this is undefined -


I am trying to get the user's latitude and longitude from the html5 location function. After that I want to get the user's current location name after using Google Maps API. This is a code that I wrote in jquery But I'm facing an error

"Type error: it is undefined"

What's going wrong here? Am I missing something?

  function getLocation () // user location {alert ("show getlocation inside"); Var LocationRenderella = document.getElementById ('Locator'); If (navigator.jolocation) {navigator.geolocation.getCurrentPosition (showPosition); } Else {locationerror.innerHTML = "Please enable the current location in your browser to get the best results. & Lt; a href = 'https://www.google.co.in/search?q=enable+current Click + location + in + Browser '> here & lt; a & gt; for help.'; }}; GetLocation (); Function showPosition (status) // The user gets the current location name {alert ("inside show status"); Mylat = position.coords.latitude; Mylang = Position. Cards.languitud; Var latlng2 = new google.maps.LatLng (mylat, MyLong); Warning (latlng2); Geocodar = new google.maps.Geocoder (); If (geocoder) {var apilink2 = "http://maps.googleapis.com/maps/api/geocode/json?"; $ Ajax ({type: "GET", url: apilink2, data: {latlng: latlng2, sensor: true}, datatype: "jsonp"}) (function (response) {warning ("done"); var Currentlocationname = response [0] .formatted_address; if (type feedback [0]. Current place name == 'undefined') {$ ('# locationerror'). InnerHTML = "your current location can not be found.";}}); Warning (currentlocationname);    

Of course, this error is you $ () < Should use jQuery () instead of / p>



No comments:

Post a Comment