9.1 Adding user data to a database

There may come a point when your application demands that you save user data for future use. For example, you may want users to “add” data to your site, so that other users can see what other users have added. This “data” needs to be stored somewhere, and the only way to do this, is to… store it somewhere.

This tutorial will take you through the steps necessary to allow users to add points, or markers to a map on your site and add relevant information about each point, and to “save” it to a database.

Step 1: Starter Code

Start with the following “starter” code:

Notice that the highlighted line shows an extra call to the google library for “drawing”. This calls the Google library that allows us to draw on the a google map.

Step 2: Adding the ability to draw on the map

Google provides us a with a library to draw points, lines and polygons on a map.  To do so, we must use the “Drawing Manager“.  First, create a container for our drawing manager in the global space:

Next, add the following call to create the functionality to draw markers on the map.  Put the following highlighted lines of code in the end of the initialize function:

The drawingManager we have created adds the following controls to the map:

(sample code)

Leave a Reply