PHP Classes

File: ex7.php

Recommend this page to a friend!
  Classes of Vagharshak Tozalakyan   Map Builder   ex7.php   Download  
File: ex7.php
Role: Example script
Content type: text/plain
Description: Example 7 - Using Geolocation service.
Class: Map Builder
Display maps using Google Maps API v3
Author: By
Last change: Added API key.
Date: 7 years ago
Size: 1,037 bytes
 

Contents

Class file image Download
<?php

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

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

// Set API key
$map->setApiKey('AIzaSyB230QxSetZoJiM9noon7FiAQXbc-HPSLU');

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

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

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

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

// Enable sensor.
// It's not required, as the sensor will turned on automatically by the following 2 methods.
$map->setSensor(true);

// Add marker at location returned by GPS sensor.
$map->addGeoMarker(array(
   
'html' => '<b>Hey, it\'s my location!</b>',
   
'defColor' => '#FF6161',
   
'defSymbol' => '%E2%80%A2',
   
'infoCloseOthers' => true
));

// Make location returned by GPS sensor the map center.
$map->overrideCenterByGeo(true);

// Display the map.
$map->show();

?>