Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined is not a function, Google Geolocation
    text
    copied!<p>I'm trying to display an address as a marker on a google map element within my page.</p> <pre><code>&lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=my_key&amp;sensor=true&amp;callback=initialize"&gt;&lt;/script&gt; &lt;script language="javascript" type="text/javascript"&gt; navigator.geolocation.getCurrentPosition(foundLocation, noLocation); var latitude; var longitude; var map; function foundLocation(position) { latitude = position.coords.latitude; longitude = position.coords.longitude; } function noLocation() { //Do something here in the case that no location is found, or user denies access } function initialize() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(latitude, longitude), mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); //setMarkers(); } function addMarker(location) { var marker = new google.maps.Marker({ position: location, map: map }); markersArray.push(marker); } &lt;/script&gt; &lt;span id="ctl00_ContentPlaceHolder1_lblGeneratedScript"&gt;&lt;script language="javascript" type="text/javascript"&gt; var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': "123 Test Dr."}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { addMarker(results[0].geometry.location); } else { alert("Geocode failed! Reason: " + status); } }); &lt;/script&gt; &lt;/span&gt; </code></pre> <p>But, on this line</p> <pre><code>var geocoder = new google.maps.Geocoder(); </code></pre> <p>I am getting an uncaught type error of "Undefined is not a function."</p> <p>I've omitted my api key in this selection of my code, as well as changed the address from what I am using to test. (my home address)</p> <p>Also, I am using ASP.NET to generate the script within the span tags.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload