Esempi e demo
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Di seguito sono elencati tutti gli esempi contenuti nella documentazione dell'API Embedded Viewer come riferimento rapido. Inoltre, sono incluse una serie di demo aggiuntive per illustrare concetti avanzati.
Esempi dalla Guida per gli sviluppatori
Questi esempi di base sono riportati nella Guida per gli sviluppatori e trattano gli utilizzi più comuni dell'API Embedded Viewer.
- book-simple
L'esempio "Hello World" dell'API Embedded Viewer indica come caricare l'API e disegnare un visualizzatore con un determinato libro.
- book-language
Questo esempio mostra come cambiare la lingua dell'interfaccia dello spettatore, in questo caso il portoghese brasiliano.
- book-notfound
Mostra come aggiungere una funzione di callback che viene chiamata quando il visualizzatore non riesce a caricare il libro specificato. Puoi basarti su questo esempio per gestire agevolmente queste condizioni.
- libro-successo
Mostra come aggiungere una funzione di callback che viene chiamata quando il visualizzatore viene inizializzato con un libro ed è pronto per essere manipolato in modo programmatico.
- book-animate
Per illustrare come il visualizzatore può essere controllato in modo programmatico tramite JavaScript, viene mostrata un'anteprima che passa automaticamente alla pagina successiva ogni tre secondi.
Controllo programmatico del visualizzatore
Lo spettatore consente di fare con il codice quasi tutto ciò che l'utente può fare interagendo con lo spettatore. Gli esempi di seguito mostrano come potrebbe essere utile.
- book-interactions-controls
Questo esempio funzionante elenca tutti i metodi di interazione supportati dal visualizzatore, tra cui le funzioni zoom, nextPage, goToPage ed evidenziazione.
- book-interactions-openatpage
Mostra come aprire automaticamente un visualizzatore di libri su una determinata pagina, utilizzando i callback e la funzione goToPage.
Combinazione con l'API Books e i Dynamic Links
Durante la creazione di applicazioni avanzate, può essere utile combinare l'API Embedded Viewer con l'API Books o la funzionalità Dynamic Links. Ad esempio, può essere utile sapere in anticipo se una determinata anteprima sarà disponibile per l'incorporamento (ad es. per determinare se offrire all'utente la possibilità di aprire una finestra di anteprima sul tuo sito). Oppure potresti non conoscere
l'identificatore di un determinato libro e potresti voler prima "cercarlo" utilizzando
l'API Books. I seguenti esempi indicano come eseguire queste operazioni.
- book-Dynamiclinks-zippy
Verifica per prima cosa se un libro è disponibile per l'incorporamento. Se e solo se è disponibile, viene visualizzata una "zippy anteprima", che, se selezionata, mostra l'anteprima del libro in linea.
- booksapi-titlesearch
Questo esempio ti consente di aprire un visualizzatore incorporato semplicemente inserendo una query di ricerca per un libro. Verrà mostrato automaticamente il primo risultato incorporabile per la query che inserisci. Viene utilizzato il formato di output JSON dell'API di dati per accedere ai risultati di ricerca.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-06-28 UTC.
[null,null,["Ultimo aggiornamento 2024-06-28 UTC."],[[["\u003cp\u003eThis documentation provides a comprehensive list of examples for Google Books Embedded Viewer API.\u003c/p\u003e\n"],["\u003cp\u003eExamples cover basic viewer setup, language settings, error handling, and programmatic control functionalities.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can learn to integrate the viewer with the Books API and Dynamic Links for advanced functionalities.\u003c/p\u003e\n"],["\u003cp\u003eSample code demonstrates interactions like zooming, navigation, and highlighting within the embedded viewer.\u003c/p\u003e\n"],["\u003cp\u003eUse cases include creating book previews, searching for books, and handling embedding availability.\u003c/p\u003e\n"]]],[],null,["# Examples and Demos\n\nAll of the examples contained within the Embedded Viewer API documentation set are listed below for quick reference. In addition, a number of additional demos are included to illustrate advanced concepts.\n\nExamples from the Developer's Guide\n-----------------------------------\n\nThese basic examples appear in the [Developer's Guide](/books/docs/viewer/developers_guide) and cover the most common uses of the Embedded Viewer API.\n\n- [book-simple](/books/docs/viewer/examples/book-simple) \n The \"Hello, World\" example of the Embedded Viewer API, this example indicates how to load the API and draw a viewer with a particular book.\n- [book-language](/books/docs/viewer/examples/book-language) \n This example shows how to change the viewer's interface language, in this case to Brazilian Portuguese.\n- [book-notfound](/books/docs/viewer/examples/book-notfound) \n This shows how to add a callback function which is called when the viewer could not load the specified book. You can build on this example to gracefully handle such conditions.\n- [book-success](/books/docs/viewer/examples/book-success) \n This shows how to add a callback function which is called when the viewer has successfully initialized with a book and is ready to be manipulated programatically.\n- [book-animate](/books/docs/viewer/examples/book-animate) \n To illustrate how the viewer can be controlled programmatically using JavaScript, a preview is shown which automatically flips to the next page every 3 seconds.\n\nProgrammatic control of the viewer\n----------------------------------\n\nThe viewer allows you to do with code almost anything the user can do by interacting with the the viewer. The examples below show how this might be useful.\n\n- [book-interactions-controls](/books/docs/viewer/examples/book-interactions-controls) \n This working example enumerates all the interaction methods supported by the viewer, including zoom, nextPage, goToPage, and highlighting functions.\n- [book-interactions-openatpage](/books/docs/viewer/examples/book-interactions-openatpage) \n Shows how to automatically open a book viewer on a particular page, using callbacks and the goToPage function.\n\nCombining with the Books API and Dynamic Links\n----------------------------------------------\n\nWhen building advanced applications, you may find it useful to combine\nthe Embedded Viewer API with either the [Books API](/books/docs/v1/getting_started) or the\n[Dynamic Links](/books/docs/dynamic-links)\nfeature. For example, it may be useful to know in advance whether a particular\npreview will be available for embedding (e.g., to determine whether to give the\nuser the option to open a preview window on your site). Or, you may not know the\nidentifier for a particular book, and want to first \"look it up\" using the Books\nAPI. The examples below indicate how to perform these operations.\n\n- [book-dynamiclinks-zippy](/books/docs/viewer/examples/book-dynamiclinks-zippy) \n Here we check whether a book is available for embedding first. If and only if it is available, we render a \"preview zippy,\" which, when clicked, shows the book preview inline.\n- [booksapi-titlesearch](/books/docs/viewer/examples/booksapi-titlesearch) \n This example allows you open an embedded viewer by simply entering a search query for a book. It will automatically show the first embeddable result for the query you enter. This uses the JSON output format of the Data API to access the search results."]]