PHP Classes

File: ex8.php

Recommend this page to a friend!
  Classes of Vagharshak Tozalakyan  >  Map Builder  >  ex8.php  >  Download  
File: ex8.php
Role: Example script
Content type: text/plain
Description: Example 8 - Filling data from database.
Class: Map Builder
Display maps using Google Maps API v3
Author: By
Last change: Added API key.
Date: 3 months ago
Size: 1,033 bytes


Class file image Download

// Include MapBuilder class.
require_once 'class.MapBuilder.php';

// Create MapBuilder object.
$map = new MapBuilder();

// Set API key

// Set map's center position by latitude and longitude coordinates.
$map->setCenter(48.860181, 2.3249648);

// Set the default map type.

// Set width and height of the map.
$map->setSize(860, 550);

// Set default zoom level.

// Connect the database.
mysql_connect('localhost', 'root', '') or die('Unable to connect the database!');
mysql_select_db('map_data') or die('Unable to select the database!');

// Select data and add markers using that data.
$result = mysql_query("SELECT name, lat, lng FROM highlights") or die(mysql_error());
while (
$row = mysql_fetch_assoc($result)) {
$map->addMarker($row['lat'], $row['lng'], array(
'title' => $row['name']

// Display the map.