Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In case you're interested in <em>why</em> this happened, it's simple: the sample was using undocumented internals of the API, so when Google updated the Maps JS file, it broke.</p> <p>More specifically, <code>Ua</code> and <code>Va</code> were auto-generated variable names resulting from <a href="http://en.wikipedia.org/wiki/Minification_%28programming%29" rel="nofollow">minification</a>. It looks like Google removed a variable in the original source and the labels shifted up (<code>Ua</code>,<code>Va</code> → <code>Ta</code>,<code>Ua</code>).</p> <p>I'll bet I know exactly how the author of the bad sample came up with his code. He inspected a <a href="https://developers.google.com/maps/documentation/javascript/reference#LatLng" rel="nofollow"><code>LatLng</code></a> (the type of object in <code>location</code> in your example) in his browser's dev tools, saw that those two oddly-named variables contained the data he wanted, and just went with it. Since the <code>lat</code> and <code>lng</code> methods are "hidden" in <code>LatLng</code>'s <code>prototype</code>, he didn't notice them.</p> <p>There are two lessons to be learned here:</p> <ol> <li><strong>Always use <a href="https://developers.google.com/maps/documentation/javascript/reference" rel="nofollow">documented API methods</a></strong>; anything else is an implementation detail that is subject to change.</li> <li>Don't trust the code on some dude's website is a <em>good</em> or even competent example of how to do things. This is especially true in the case of Google Maps, where there's extensive documentation and official examples.</li> </ol>
 

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