<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div style="font-size:12.8000001907349px">Hello <span style="font-size:12.8000001907349px">Mapguides List,</span></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I am developing an aplication about vehicle tracking and i have beed reading the MgOpenSourceDevGuide.pdf. </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I need to draw the car image about location on the map but i don´t understand how to do it.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Coul you help me with this please.</div><div><br></div><div><br></div><div>My code is the follow:</div><div><br></div><div><br></div><div><br></div><div><div><br></div><div><html></div><div><br></div><div><body onLoad="OnPageLoad()"></div><div><br></div><div><?php </div><div>function add_layer_definition_to_map($layerDefinition, $layerName, $layerLegendLabel, $sessionId, $resourceService, $map)</div><div>// Adds the layer definition (XML) to the map.</div><div>// Returns the layer.</div><div>{</div><div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>echo "Iniciando metodo add_layer_definition_to_map...";</div><div>    global $schemaDirectory;</div><div><br></div><div>    // Validate the XML.</div><div>    $domDocument = new DOMDocument;</div><div>    $domDocument->loadXML($layerDefinition);</div><div><br></div><div><br></div><div>    // Save the new layer definition to the session repository</div><div>    $byteSource = new MgByteSource($layerDefinition, strlen($layerDefinition));</div><div><span style="white-space:pre-wrap">    </span>echo "<br/> echo 111 <br/>";</div><div>    $byteSource->SetMimeType(MgMimeType::Xml);</div><div><span style="white-space:pre-wrap">     </span>echo "<br/> echo 2222 <br/>";</div><div><span style="white-space:pre-wrap">      </span>echo "session: ".$sessionId;</div><div>    $resourceID = new MgResourceIdentifier("Session:$sessionId//$layerName.LayerDefinition");</div><div><span style="white-space:pre-wrap">   </span>echo "<br/> echo 3333 <br/>";</div><div>    $resourceService->SetResource($resourceID, $byteSource->GetReader(), null);</div><div>echo "<br/> echo 4444 <br/>";</div><div>    $newLayer = add_layer_resource_to_map($resourceID, $resourceService, $layerName, $layerLegendLabel, $map);</div><div>echo "<br/> echo 5555 <br/>";</div><div>    return $newLayer;</div><div>}</div><div><br></div><div><br></div><div>function add_layer_resource_to_map($layerResourceID, $resourceService, $layerName, $layerLegendLabel, $map)</div><div>// Adds a layer defition (which can be stored either in the Library or a session</div><div>// repository) to the map.</div><div>// Returns the layer.</div><div>{</div><div>    $newLayer = new MgLayer($layerResourceID, $resourceService);</div><div><br></div><div>    // Add the new layer to the map's layer collection</div><div>    $newLayer->SetName($layerName);</div><div>    $newLayer->SetVisible(true);</div><div>    $newLayer->SetLegendLabel($layerLegendLabel);</div><div>    $newLayer->SetDisplayInLegend(true);</div><div><span style="white-space:pre-wrap">      </span>$newLayer->SetDisplayInLegend(true);</div><div>    $layerCollection = $map->GetLayers();</div><div>    if (! $layerCollection->Contains($layerName) )</div><div>    {</div><div>        // Insert the new layer at position 0 so it is at the top</div><div>        // of the drawing order</div><div>        $layerCollection->Insert(0, $newLayer);</div><div>    }</div><div><br></div><div>    return $newLayer;</div><div>}</div><div><br></div><div><br></div><div>?> </div><div><br></div><div><?php </div><div><br></div><div>try{</div><div><span style="white-space:pre-wrap">   </span></div><div><span style="white-space:pre-wrap"> </span>define('__ROOT__', dirname(dirname(__FILE__))); </div><div><span style="white-space:pre-wrap">        </span>require_once(__ROOT__.'/../phpsamples/common/common.php');</div><div><span style="white-space:pre-wrap">       </span>echo "ferez".__ROOT__.'/../findaddress/layerdefinitionfactory.php';</div><div><span style="white-space:pre-wrap">    </span>require_once(__ROOT__.'/findaddress/layerdefinitionfactory.php');</div><div><span style="white-space:pre-wrap">        </span></div><div><br></div><div>         // Get the session information passed from the viewer.</div><div>         $args = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST : $_GET;</div><div>         $mgSessionId = $args['SESSION'];</div><div>         $mgMapName = $args['MAPNAME'];</div><div><br></div><div><span style="white-space:pre-wrap">              </span> // Initialize the web extensions,</div><div><span style="white-space:pre-wrap">               </span> MgInitializeWebTier ($webconfigFilePath);</div><div><span style="white-space:pre-wrap">               </span> </div><div>         // Get the user information using the session id,</div><div>         // and set up a connection to the site server.</div><div>         $userInfo = new MgUserInformation($mgSessionId);</div><div>         $siteConnection = new MgSiteConnection();</div><div>         $siteConnection->Open($userInfo);</div><div><br></div><div><span style="white-space:pre-wrap">         </span> </div><div><span style="white-space:pre-wrap">               </span> echo "Instanciamos Feature service <br/><br/>";</div><div><span style="white-space:pre-wrap">           </span>$featureService = $siteConnection->CreateService(MgServiceType::FeatureService);</div><div><span style="white-space:pre-wrap">              </span>echo "Instanciamos Resource service <br/><br/>";</div><div><span style="white-space:pre-wrap">           </span>$resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);</div><div><span style="white-space:pre-wrap">            </span>echo "Instanciamos ResourceIdentifier <br/><br/>"; </div><div><span style="white-space:pre-wrap">               </span>$bufferFeatureResId = new MgResourceIdentifier("Session:" . $mgSessionId . "//Buffer.FeatureSource");</div><div><span style="white-space:pre-wrap">                </span> </div><div><span style="white-space:pre-wrap">               </span>$map = new MgMap($siteConnection);</div><div><span style="white-space:pre-wrap">               </span>$map->Open($resourceService, $mgMapName);</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">           </span>// Set up some objects for coordinate conversion</div><div><span style="white-space:pre-wrap">         </span>$mapWktSrs = $map->GetMapSRS();</div><div><span style="white-space:pre-wrap">               </span>$agfReaderWriter = new MgAgfReaderWriter();</div><div><span style="white-space:pre-wrap">              </span>$wktReaderWriter = new MgWktReaderWriter();</div><div><span style="white-space:pre-wrap">              </span></div><div><span style="white-space:pre-wrap">         </span>echo "Creando FeatureSource <br/><br/>";</div><div><span style="white-space:pre-wrap">           </span>echo "<br/> echo 1 <br/>";</div><div><span style="white-space:pre-wrap">         </span></div><div><span style="white-space:pre-wrap">         </span></div><div><span style="white-space:pre-wrap">         </span>// Create a temporary feature source</div><div><span style="white-space:pre-wrap">             </span>$bufferClass = new MgClassDefinition();</div><div><span style="white-space:pre-wrap">          </span>$className = 'BufferClass';</div><div><span style="white-space:pre-wrap">              </span>$bufferClass->SetName('BufferClass');</div><div><span style="white-space:pre-wrap">         </span>$properties = $bufferClass->GetProperties();</div><div><br></div><div><span style="white-space:pre-wrap">         </span>$idProperty = new MgDataPropertyDefinition('ID');</div><div><span style="white-space:pre-wrap">                </span>$idProperty->SetDataType(MgPropertyType::Int32);</div><div><span style="white-space:pre-wrap">              </span>$idProperty->SetReadOnly(true);</div><div><span style="white-space:pre-wrap">               </span>$idProperty->SetNullable(false);</div><div><span style="white-space:pre-wrap">              </span>$idProperty->SetAutoGeneration(true);</div><div><span style="white-space:pre-wrap">         </span>$properties->Add($idProperty);</div><div><br></div><div><span style="white-space:pre-wrap">               </span>$polygonProperty = new MgGeometricPropertyDefinition('BufferGeometry');</div><div><span style="white-space:pre-wrap">          </span>$polygonProperty->SetGeometryTypes(MgFeatureGeometricType::Point);</div><div><span style="white-space:pre-wrap">            </span>$polygonProperty->SetHasElevation(false);</div><div><span style="white-space:pre-wrap">             </span>$polygonProperty->SetHasMeasure(false);</div><div><span style="white-space:pre-wrap">               </span>$polygonProperty->SetReadOnly(false);</div><div><span style="white-space:pre-wrap">         </span>$polygonProperty->SetSpatialContextAssociation('defaultSrs');</div><div><span style="white-space:pre-wrap">         </span>$properties->Add($polygonProperty);</div><div><br></div><div><span style="white-space:pre-wrap">          </span>$idProperties = $bufferClass->GetIdentityProperties();</div><div><span style="white-space:pre-wrap">                </span>$idProperties->Add($idProperty);</div><div><br></div><div><span style="white-space:pre-wrap">             </span>$bufferClass->SetDefaultGeometryPropertyName('BufferGeometry');</div><div><span style="white-space:pre-wrap">               </span>$bufferSchema = new MgFeatureSchema('BufferLayerSchema', 'temporary schema to hold a buffer');</div><div><span style="white-space:pre-wrap">           </span>$bufferSchema->GetClasses()->Add($bufferClass);</div><div><span style="white-space:pre-wrap">            </span>$sdfParams = new MgCreateSdfParams('defaultSrs', $mapWktSrs, $bufferSchema);</div><div><span style="white-space:pre-wrap">             </span>$featureService->CreateFeatureSource($bufferFeatureResId, $sdfParams);</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">         </span>echo "<br/> echo 2 <br/>";</div><div><span style="white-space:pre-wrap">         </span>//--------------------Creamos Layer Definition-------------------------------//</div><div><span style="white-space:pre-wrap">          </span>// ...</div><div><span style="white-space:pre-wrap">           </span>//---------------------------------------------------//</div><div><span style="white-space:pre-wrap">          </span>echo "<br/> echo 3 <br/>";</div><div><span style="white-space:pre-wrap">         </span>$factory = new LayerDefinitionFactory();</div><div><span style="white-space:pre-wrap">         </span>echo "<br/> echo 4 <br/>";</div><div><span style="white-space:pre-wrap">         </span>// Create a mark symbol</div><div><span style="white-space:pre-wrap">          </span>$resourceId = 'Library://Samples/Sheboygan/Symbols/BasicSymbols.SymbolLibrary';</div><div><span style="white-space:pre-wrap">          </span>$symbolName = 'PushPin';</div><div><span style="white-space:pre-wrap">         </span>$width = '100'; // points</div><div><span style="white-space:pre-wrap">                </span>$height = '100'; // points</div><div><span style="white-space:pre-wrap">               </span>$color = 'FFFF0000';</div><div><span style="white-space:pre-wrap">             </span>$markSymbol = $factory->CreateMarkSymbol($resourceId, $symbolName, $width, $height, $color);</div><div><br></div><div><span style="white-space:pre-wrap">         </span>// Create a text symbol</div><div><span style="white-space:pre-wrap">          </span>$text = "ID";</div><div><span style="white-space:pre-wrap">          </span>$fontHeight="100";</div><div><span style="white-space:pre-wrap">             </span>$foregroundColor = 'FF000000';</div><div><span style="white-space:pre-wrap">           </span>$textSymbol = $factory->CreateTextSymbol($text, $fontHeight, $foregroundColor);</div><div><span style="white-space:pre-wrap">               </span>// Create a point rule.</div><div><span style="white-space:pre-wrap">          </span>$legendLabel = 'trees';</div><div><span style="white-space:pre-wrap">          </span>$filter = '';</div><div><span style="white-space:pre-wrap">            </span>$pointRule = $factory->CreatePointRule($legendLabel, $filter, $textSymbol, $markSymbol);</div><div><br></div><div><span style="white-space:pre-wrap">             </span>// Create a point type style.</div><div><span style="white-space:pre-wrap">            </span>$pointTypeStyle = $factory->CreatepointTypeStyle($pointRule);</div><div><br></div><div><span style="white-space:pre-wrap">                </span>// Create a scale range.</div><div><span style="white-space:pre-wrap">         </span>$minScale = '0';</div><div><span style="white-space:pre-wrap">         </span>$maxScale = '1000000000000';</div><div><span style="white-space:pre-wrap">             </span>$pointScaleRange = $factory->CreateScaleRange($minScale, $maxScale, $pointTypeStyle);</div><div><span style="white-space:pre-wrap">         </span>// Create the layer definiton.</div><div><span style="white-space:pre-wrap">           </span>$featureClass = 'Library://Tests/Trees.FeatureSource';</div><div><span style="white-space:pre-wrap">           </span>$featureName = 'Default:Trees';</div><div><span style="white-space:pre-wrap">          </span>$geometry = 'SHPGEOM';</div><div><span style="white-space:pre-wrap">           </span>$layerDefinition = $factory->CreateLayerDefinition($bufferFeatureResId, $featureName, $geometry, $pointScaleRange);</div><div><span style="white-space:pre-wrap">           </span>$layerName = "capaferez";</div><div><span style="white-space:pre-wrap">              </span>$layerLegendLabel = "capaferez";</div><div><span style="white-space:pre-wrap">               </span></div><div><span style="white-space:pre-wrap">         </span>$nuevaLayer = add_layer_definition_to_map($layerDefinition, $layerName, $layerLegendLabel, $mgSessionId, $resourceService, $map);</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">         </span>echo "<br/> inicio insercion feature actualizando fea 1<br/>";</div><div><span style="white-space:pre-wrap">             </span>$commands = new MgFeatureCommandCollection();</div><div><span style="white-space:pre-wrap">            </span>$properties = new MgPropertyCollection();</div><div>echo "lllllllllllllllllllllllllllllllll";</div><div><span style="white-space:pre-wrap">              </span> // create a coordinate</div><div><span style="white-space:pre-wrap">          </span> $geometryFactory = new MgGeometryFactory();</div><div><span style="white-space:pre-wrap">             </span> $coordinate = $geometryFactory->CreateCoordinateXY(-87.755686,43.719265);</div><div><span style="white-space:pre-wrap">            </span> echo "oooooooooooooooooooooooo";</div><div><span style="white-space:pre-wrap">              </span> // create a point</div><div><span style="white-space:pre-wrap">               </span> $point = $geometryFactory->CreatePoint($coordinate);</div><div><span style="white-space:pre-wrap">         </span> echo "Creando MgPoint ...";</div><div><span style="white-space:pre-wrap">           </span> $pointAgfText = $wktReaderWriter->Write($point);</div><div><span style="white-space:pre-wrap">             </span> echo "AGF Text representation of Point: $pointAgfText\n";</div><div><span style="white-space:pre-wrap">             </span>echo " agfByteStream ...";</div><div><span style="white-space:pre-wrap">             </span> $agfByteStream = $agfReaderWriter->Write($point);</div><div><span style="white-space:pre-wrap">            </span> echo " punto creado ...";</div><div><br></div><div><span style="white-space:pre-wrap">            </span></div><div><span style="white-space:pre-wrap">         </span>$geometryProperty = new MgGeometryProperty('BufferGeometry', $agfByteStream);</div><div><span style="white-space:pre-wrap">            </span>$properties->Add($geometryProperty);</div><div><br></div><div><span style="white-space:pre-wrap">         </span>$insertCommand = new MgInsertFeatures($className, $properties);</div><div><span style="white-space:pre-wrap">          </span>$commands->Add($insertCommand);</div><div><span style="white-space:pre-wrap">               </span></div><div><span style="white-space:pre-wrap">         </span></div><div><br></div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">         </span></div><div><br></div><div>echo "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk";</div><div><span style="white-space:pre-wrap">         </span>$featureService->UpdateFeatures($bufferFeatureResId, $commands, false);</div><div>echo "fffffffffffffffffffffffffffffffffff";</div><div><span style="white-space:pre-wrap">           </span> </div><div><span style="white-space:pre-wrap">               </span>echo "<br/> fin insercion feature actualizando fea 1<br/>";</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">         </span>$nuevaLayer->SetVisible(true);</div><div><span style="white-space:pre-wrap">                </span>$nuevaLayer->ForceRefresh();</div><div><span style="white-space:pre-wrap">          </span>$nuevaLayer->SetDisplayInLegend(true);</div><div><span style="white-space:pre-wrap">                </span>$nuevaLayer->SetSelectable(false);</div><div><span style="white-space:pre-wrap">            </span>//If you created a MgMap with a MgSiteConnection</div><div><span style="white-space:pre-wrap">         </span>$map->Save();<span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">         </span>echo "Fin creacion feature source <br/><br/>";</div><div><br></div><div><span style="white-space:pre-wrap">            </span>echo "<br/><br/>Finaliza<br/>";</div><div>}catch (MgException $e){</div><div><span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span>echo $e->GetStackTrace() . "<br />";</div><div>}catch (Exception $ex) {</div><div>    echo 'Excepción capturada: ',  $e->getMessage(), "\n";</div><div>}</div><div><br></div><div>?> </div><div><br></div><div><br></div><div><script language="javascript"></div><div><span style="white-space:pre-wrap">   </span>function OnPageLoad()</div><div><span style="white-space:pre-wrap">    </span>{</div><div><span style="white-space:pre-wrap">                </span>alert("probando");</div><div><span style="white-space:pre-wrap">             </span>parent.parent.Refresh();</div><div><span style="white-space:pre-wrap"> </span>}</div><div></script></div><div><br></div><div></body></div><div></html></div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><div><br></div><div><br></div>-- <br><div><div dir="ltr"><div style="color:rgb(136,136,136)">Ing. Julian Felipe Feres Santander<br></div><div style="color:rgb(136,136,136)">Ingeniero De Software<br><div><br></div><div><br></div></div></div></div>
</font></span></div>
</div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div style="color:rgb(136,136,136)">Ing. Julian Felipe Feres Santander<br></div><div style="color:rgb(136,136,136)">Ingeniero De Software<br><div><br></div><div><br></div></div></div></div>
</div>