On Github AnnieCannons / ac-introduction-to-apis
Have you ever wondered how Facebook is able to automatically display your Instagram photos?
As a programmer, you don't want to install a database of the all world’s addresses and algorithms in order to search them on your server. (hint: just use Google's API)
It would be easier to just use the Google Maps API to geocode an address!2. Public Data: There is a huge amount of data available, and APIs make that data available to use in a structured way.
3. User Data: We also use APIs to access data from other products and integrate them with our own. Users use multiple products and expect for them to work together - synergy.
APIs are so useful! We need to understand HOW to best use APIs, WHAT APIs are out there, and WHY you should use them.
Watch this! And this!The Google Maps API is a JavaScript library. It can be added to a web page with a script tag:
Create a function to initialize the map:
function initialize() {
}
In the initialize function, create an object (mapProp) to define the properties for the map:
var mapProp = {
center:new google.maps.LatLng(51.508742, -0.120850),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Create a div element to hold the map. Use CSS to size the element:
var map=new google.maps.Map(document.getElementById("googleMap"), mapProp);
The code above creates a new map inside the div element with id="googleMap", using the parameters that are passed (mapProp).
Add a DOM listener that will execute the initialize() function on window load (when the page is loaded):
google.maps.event.addDomListener(window, 'load', initialize);
Go to Snazzy Maps and find a map style that you like and copy it.
var map = new google.maps.Map(document.getElementById('googleMap'), {
center: // Add your location here
zoom: //Add your zoom here
styles: //Add your array here
});
Make your new map!
Learn How To Use Youtube's API
Thank you for your attention!