Login   Register  
PHP Classes
elePHPant
Icontem

File: ex8.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: typo fix
Date: 1 year ago
Size: 955 bytes
 

Contents

Class file image Download
<?php

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

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

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

// Set the default map type.
$map->setMapTypeId(MapBuilder::MAP_TYPE_ID_ROADMAP);

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

// Set default zoom level.
$map->setZoom(14);

// 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.
$map->show();

?>