Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
The Web Warrior Guide to Web Design Technologies
Objective Understand web-based digital media production methods, software, and hardware. Course Weight : 10%
HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
App Inventor Barb Ericson July 3, 2013.
Information Technology Center Hany Abdelwahab Computer Specialist.
Chapter 14 Introduction to HTML
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
Canvas, SVG, Workers Doncho Minkov Telerik Corporation
Creating a MagicInfo Pro Screen Template
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
Advanced Web Design Scripting Tutorial Chapters. Scripting Intro The scripting part of the forthcoming Advanced Web Design textbook introduces you to.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
Google Maps API. Static Maps send an HTTP GET request receive an image (PNG, GIF, JPEG) no javascript needed encode params in URL example:
Programming Games Basic HTML5 audio example. Catch-up. Work on basic video. Homework: Complete basic video.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
Programming Games Google Map API examples. CSS. Classwork/homework: Catch up. Upload work. Show your [more] complex Google Maps API example. Plan your.
Programming Games Show your simple video. More video examples. Audio. Classwork/Homework: Produce more complex video program.
Programming games Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.
Creating User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
Session: 19. © Aptech Ltd. 2HTML5 Geolocation and APIs / Session 19  Explain geolocation and its use in HTML5  Explain the Google Maps API  Explain.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Web Development 101 Presented by John Valance
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
Creating Interfaces Show form validation examples, Hangman. HTML5 with Google Maps API. Add in localStorage. Design pitfalls. Homework: Make proposal for.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
CompSci Introduction to Jam’s Video Game Package.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
Positioning Objects with CSS and Tables
Understanding JavaScript and Coding Essentials Lesson 8.
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
CSS IS A LANGUAGE DESIGNED TO TARGET HTML ELEMENTS AND NODES BY TYPE, CLASS, ID AND VALUE, AND CHANGE THEIR VALUES CSS – change how your HTML looks and.
®® Microsoft Windows 7 Windows Tutorial 7 Managing Multimedia Files.
Understanding Web-Based Digital Media Production Methods, Software, and Hardware Objective
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
IN THIS LESSON WE WILL REVIEW THE STRUCTURE OF THE INTERNET AND HOW BROWSERS ASSEMBLE WEBSITES BASED ON INSTRUCTIONS THEY RECEIVE FROM SERVERS. Internet.
JavaScript, Sixth Edition
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
Lecture 9: Extra Features and Web Design Tarik Booker CS 120 California State University, Los Angeles.
1 Using the Google Maps JavaScript API. 2 The Google Maps APIs Permit web applications to use functionality of google maps. Documentation:
Creating Databases Example using Google Maps API + file creation. Dollar sign problem. Classwork/Homework: [catch up]. Work on final project.
Creating Databases Example using Google Maps API + file creation. Dollar sign problem. Classwork/Homework: [catch up]. Work on final project.
Objective % Select and utilize tools to design and develop websites.
What is a Function Expression?
Objective % Select and utilize tools to design and develop websites.
Introduction to JavaScript
The Canvas.
A second look at JavaScript
Chapter 27 WWW and HTTP.
Geolocation using Google maps
Objective Understand web-based digital media production methods, software, and hardware. Course Weight : 10%
Introduction to JavaScript
Programming games Share your plans for your virtual something.
Catchup. Work on project.
Creating User Interfaces
Geolocation using Google maps
Presentation transcript:

Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up. Show simple Google Maps. Plan Google Maps application.

Recap Access Google Maps API using external script element JavaScript code to bring in a map, with specific options, to a div element in the document. Can have more than one such place.

Map options center of map: given as a Google Maps API latlng object. Holds latitude, longitude values type of map: given as a Google Maps API constant: TERRAIN, ROADMAP, SATELLITE zoom level: number icon: image marking center more…

Lat lng units Experiment to see how close values are. Compare: -80, +80, 280, -280, 180,… Google Maps API also provides ways to use addresses and also do reverse lookup (lat long to address)

HTML document in sensor=false in

somewhere in the code // Determine the base location: replace ??? with actual values mylat = ???; mylong = ???; blatlng = new google.maps.LatLng(mylat, mylong); myOptions = { zoom: 12, center: blatlng, mapTypeId: google.maps.MapTypeId.ROADMAP}; map = new google.maps.Map(document.getElementById("place"). myOptions);

basic example

Basic map function init() { blatlng = new google.maps.LatLng( , ); myOptions = { zoom: 14, center: blatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("place"), myOptions); }

What comes next Examples of features you can use. Listen for general understanding, but don’t be overly concerned with details. Examine coding in the examples. Programs ARE putting together features based on your ideas and logic.

My ideas Set of maps, that is, locations A combination of light and shadow moving with the mouse over a map draw something on canvas, which would be transparent My cursor (fluorescent light bulb) Interactions with user (player) Compute and report distances

Spotlight The spotlight program uses Google Maps event handling AND mouse on canvas events. Substitutes default cursor with image I made. Uses alpha for color. Creates a mask.

Before next example: arrays Using an array of locations. This is an array of arrays. Inner arrays have 2 elements, holding latitude and longitude values, so…. locations[0][0] is the latitude and locations[0][1] is the longitude

Events in Spotlight example Make use of three events on canvas: ‘mousemove’ invokes showshadow ‘mousedown’ invokes pushcanvasunder ‘mouseout’ invokes clearshadow These are 3 functions I WROTE to draw spotlight & shadow centered at mouse; make map on top of canvas; clear the canvas. One event on the map: listener = google.maps.event.addListener(map, 'mouseup', function(event) { checkit(event.latLng); });

Drawing spotlight … means drawing a path to be filled in with a color with an alpha setting var grayshadow = “rgba(250,250,250,.8)”; Remember: rgb(255,255,255) is white, so the graymatter variable indicates.8 opaque of something grayish…

Cursor Built-in cursors and your own cursors can.style.cursor = “url(‘light.gif’),pointer”; Switches cursor for moving on canvas to be image I uploaded or, if not available, the built-in pointer. I also created & uploaded small red & black hand drawn x’s for icon in maps.

Spotlight The spotlight program uses Google Maps event handling AND mouse on canvas events. Substitutes default cursor with image I made. Uses alpha for color. Creates a mask.

Map and media Associates positions with media. Player clicks on map. If close enough, media is presented. Note use of CSS and coding to keep video, images, audio controls invisible until appropriate. Quiz separate logic and content!

Mediaquizcontent.js I separated program from content and mediaquizcontent.js is the name of the file holding the content, meaning the specification for the video at the locations. You can’t tell that from outward display. Look at head element in code You can read about it in HTML5 and JavaScript Projects in the Library.

var base= [ , ,"Purchase College/SUNY"]; var zoomlevel = 13;

var precontent = [ [ , ,"Esther at home","pictureaudio","estherT","es ther.jpg"], [ , ,"Lego robot ","video","maze"], [ , ,"Fire works ","video","sfire3"], [ , ,"Aviva in Dixon","picture","avivadixon.jpg"] ];

var questions = [ "Where does Grandma Esther live?", "Show the Lego robot navigating a maze.", "Where are great fireworks?", "Find where Aviva played the flute.” ];

var questions = [ "Where does Grandma Esther live?", "Show the Lego robot navigating a maze.", "Where are great fireworks?", "Find where Aviva played the flute.” ];

Dynamic creation of elements New example inspired by student: html5/videogame/videogame.html html5/videogame/videogame.html Article and others: morehtml5examples.html morehtml5examples.html

Street view mapstreet.htmlhttp://faculty.purchase.edu/jeanine.meyer/html5/ mapstreet.html Set location More realistic example would have user/player make choices or click on screen or ??? My code does Allow for a street view (aka panorama) not existing Note also heading and pitch. EXPERIMENT!

Create element Use a template May make substitutions May put into innerHTML Need to addChild Need to position Produce string for style.top and style.left. The strings end in “px”

Callbacks In many situations, action is not immediate, aka asynchronous The code sets up an action AND specifies a function (by name or defined as autonomous function) to be called when action is complete. This is the callback sv.getPanoramaByLocation(mtk,2000, processSVData); The function processSVData does the remaining work.

Responsive Adaptive Design What if I want this program to work…adapt…be responsive to different window sizes? Various techniques For this, I use percentages in the width and height property values:

Other responsive design technique In the element, query and a class col of div.

Examine code eyer/html5/mapstreet.html eyer/html5/mapstreet.html Note: init function Create the SV object Associative arrays for map and for panorama The target DIVs for map and panorama set differently Global variables Required since not everything is done in the init function

NOTE Callbacks are another type of event handling Start or set up event Specify code to handle (respond) to event Applies to other features See next: Geolocation Using percentages and other Responsive Adaptive design techniques applicable to other situations

Geolocation This is a standard that is separate from HTML5. The browser uses what it can to determine location. –IP addresses –triangulation using cell phone towers –triangulation using GPS satellites –triangulation using wireless hot spots –?

Geolocation example Used with php to send to someone with 'found' location. ml

Re: the php file The file send p.php runs on the server, NOT the client (not the user’s computer). It is written in the php language You can’t look at it in the normal way! You can find it in my HTML5 and JavaScript Projects book in the Library. PLUG: We learn to use php in the Creating Databases course

Classwork / homework Catch up Produce your own simple = basic HTML and JavaScript document bringing in a map. Use your own location (and understand how to change it), set zoom and set type (and understand how to change it). Plan and execute [slightly more] complex example.