I find that I understand much of the Javascript concepts used in the Google Maps API code, but then again there is quite a bit that is way over my head in syntax.
For example, the geocoder syntax seems to be of Ajax form, though I don’t understand what is happening under the hood (especially with lines like results[0].geometry.location
). I am able to modify the body of if (status == google.maps.GeocoderStatus.OK)
for different purposes though.
So, being that I am able to take various code from the Developer’s Guide and rework it to an extent for my own purposes, all the while not fully understanding what Google Maps is actually doing, does this make me a copy-paste programmer?
Is this a bad practice, or is this professionally viable? I am, of course, interested in learning as much as I can, but what if time-constraints outweigh the learning process?
I wouldn’t be concerned. When using an API there are different modes or reasons in using the API – all of them geared at helping developers complete their task in using the API. Google provides documentation for just this purpose – to use the tool in the way that you need.
Web APIs can also be a special case of publishers providing the ‘boilerplate’, letting you focus on the task rather than digging into the API design, etc.
1
When in doubt, set a breakpoint or call console.log
and examine the data. It’s better (in my opinion) to take a little while to learn the basics than to change things blindly and hope for the best. You don’t need to have a full understanding of how the API works, but the more that you know, the easier it will be to make it work for you.
In the case of results[0].geometry.location
results
is an array that contains at least one object which has a field named geometry
containing an object. This geometry
object has a field named location
which is most likely an object with two fields for lat
itude and long
itude.
1