How to Create a Database With Addresses Linked to a Map

Interactive map applications, such as Google Maps, allow developers to create custom-made maps for their clients. Custom-made maps display markers for addresses defined within the database. For example, a restaurant review website might provide a map showing all the restaurants within a given city. These maps allow users a visual way to access the information contained within the database. Learning how to create a database with addresses linked to a map is the first step in creating a custom-made map.

Instructions

    • 1

      Create a table in your database to contain the information for your map markers. Use the commands specific to your database system. For example, in SQL, the command to create a table is "CREATE TABLE markers ("

    • 2

      Define the identifying fields for the markers following the syntax of your database system. In SQL, provide the name of the field (such as "id" or "name") followed by the type of value and whether the field can be blank. For example, "CREATE TABLE markers ('id' INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 'name' VARCHAR(80) NOT NULL, 'address' VARCHAR(80) NOT NULL" creates a table the fields "id," "name" and "address."

    • 3

      Add fields for latitude and longitude. Map applications use latitude and longitude to identify addresses. Define the field to accept float values (numbers with decimal points) for a total of 10 digits, with up to six digits after the decimal. For example, in SQL add the fields as " 'lat' FLOAT(10,6) NOT NULL, 'lng' FLOAT(10,6) NOT NULL" in your table.

    • 4

      Follow the application programming interface (API) instructions for how to generate a map from the application using your database. For example, Google Map's API recommends using PHP scripting to generate an XML file from your database.

Learnify Hub © www.0685.com All Rights Reserved