Hello Mapguides List,
I am developing an aplication about vehicle tracking and i have beed
reading the MgOpenSourceDevGuide.pdf.
I need to draw the car image about location on the map but i don´t
understand how to do it.
Coul you help me with this please.
My code is the follow:
html
body onLoad=OnPageLoad()
?php
function add_layer_definition_to_map($layerDefinition, $layerName,
$layerLegendLabel, $sessionId, $resourceService, $map)
// Adds the layer definition (XML) to the map.
// Returns the layer.
{
echo Iniciando metodo add_layer_definition_to_map...;
global $schemaDirectory;
// Validate the XML.
$domDocument = new DOMDocument;
$domDocument-loadXML($layerDefinition);
// Save the new layer definition to the session repository
$byteSource = new MgByteSource($layerDefinition,
strlen($layerDefinition));
echo br/ echo 111 br/;
$byteSource-SetMimeType(MgMimeType::Xml);
echo br/ echo br/;
echo session: .$sessionId;
$resourceID = new
MgResourceIdentifier(Session:$sessionId//$layerName.LayerDefinition);
echo br/ echo br/;
$resourceService-SetResource($resourceID, $byteSource-GetReader(),
null);
echo br/ echo br/;
$newLayer = add_layer_resource_to_map($resourceID, $resourceService,
$layerName, $layerLegendLabel, $map);
echo br/ echo br/;
return $newLayer;
}
function add_layer_resource_to_map($layerResourceID, $resourceService,
$layerName, $layerLegendLabel, $map)
// Adds a layer defition (which can be stored either in the Library or a
session
// repository) to the map.
// Returns the layer.
{
$newLayer = new MgLayer($layerResourceID, $resourceService);
// Add the new layer to the map's layer collection
$newLayer-SetName($layerName);
$newLayer-SetVisible(true);
$newLayer-SetLegendLabel($layerLegendLabel);
$newLayer-SetDisplayInLegend(true);
$newLayer-SetDisplayInLegend(true);
$layerCollection = $map-GetLayers();
if (! $layerCollection-Contains($layerName) )
{
// Insert the new layer at position 0 so it is at the top
// of the drawing order
$layerCollection-Insert(0, $newLayer);
}
return $newLayer;
}
?
?php
try{
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/../phpsamples/common/common.php');
echo ferez.__ROOT__.'/../findaddress/layerdefinitionfactory.php';
require_once(__ROOT__.'/findaddress/layerdefinitionfactory.php');
// Get the session information passed from the viewer.
$args = ($_SERVER['REQUEST_METHOD'] == POST)? $_POST : $_GET;
$mgSessionId = $args['SESSION'];
$mgMapName = $args['MAPNAME'];
// Initialize the web extensions,
MgInitializeWebTier ($webconfigFilePath);
// Get the user information using the session id,
// and set up a connection to the site server.
$userInfo = new MgUserInformation($mgSessionId);
$siteConnection = new MgSiteConnection();
$siteConnection-Open($userInfo);
echo Instanciamos Feature service br/br/;
$featureService =
$siteConnection-CreateService(MgServiceType::FeatureService);
echo Instanciamos Resource service br/br/;
$resourceService =
$siteConnection-CreateService(MgServiceType::ResourceService);
echo Instanciamos ResourceIdentifier br/br/;
$bufferFeatureResId = new MgResourceIdentifier(Session: . $mgSessionId .
//Buffer.FeatureSource);
$map = new MgMap($siteConnection);
$map-Open($resourceService, $mgMapName);
// Set up some objects for coordinate conversion
$mapWktSrs = $map-GetMapSRS();
$agfReaderWriter = new MgAgfReaderWriter();
$wktReaderWriter = new MgWktReaderWriter();
echo Creando FeatureSource br/br/;
echo br/ echo 1 br/;
// Create a temporary feature source
$bufferClass = new MgClassDefinition();
$className = 'BufferClass';
$bufferClass-SetName('BufferClass');
$properties = $bufferClass-GetProperties();
$idProperty = new MgDataPropertyDefinition('ID');
$idProperty-SetDataType(MgPropertyType::Int32);
$idProperty-SetReadOnly(true);
$idProperty-SetNullable(false);
$idProperty-SetAutoGeneration(true);
$properties-Add($idProperty);
$polygonProperty = new MgGeometricPropertyDefinition('BufferGeometry');
$polygonProperty-SetGeometryTypes(MgFeatureGeometricType::Point);
$polygonProperty-SetHasElevation(false);
$polygonProperty-SetHasMeasure(false);
$polygonProperty-SetReadOnly(false);
$polygonProperty-SetSpatialContextAssociation('defaultSrs');
$properties-Add($polygonProperty);
$idProperties = $bufferClass-GetIdentityProperties();
$idProperties-Add($idProperty);
$bufferClass-SetDefaultGeometryPropertyName('BufferGeometry');
$bufferSchema = new MgFeatureSchema('BufferLayerSchema', 'temporary schema
to hold a buffer');
$bufferSchema-GetClasses()-Add($bufferClass);
$sdfParams = new MgCreateSdfParams('defaultSrs', $mapWktSrs, $bufferSchema);
$featureService-CreateFeatureSource($bufferFeatureResId, $sdfParams);
echo br/ echo 2 br/;
//Creamos Layer