Example #1
0
 $cred->SetClientAgent(GetClientAgent());
 //connect to the site and get a feature service and a resource service instances
 $site = new MgSiteConnection();
 $site->Open($cred);
 $featureSrvc = $site->CreateService(MgServiceType::FeatureService);
 $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
 $dataSourceId = new MgResourceIdentifier($dataSource);
 $layerDefId = new MgResourceIdentifier($layerDef);
 //load the map runtime state
 //
 $map = new MgMap();
 $map->Open($resourceSrvc, $mapName);
 //locate the buffer layer in the map. It might or might not already exist
 //
 $layers = $map->GetLayers();
 $layer = FindLayer($layers, $bufferName);
 $layerNames = explode(",", $layersParam);
 // convert distance to meters
 if ($units == "mi") {
     //miles
     $distance *= 1609.35;
 } else {
     if ($units == "ki") {
         //kilometers
         $distance *= 1000;
     } else {
         if ($units == "fe") {
             //feet
             $distance *= 0.3048;
         }
     }
Example #2
0
function add_layer_resource_to_map($layerResourceID, $resourceService, $layerDef, $layerLegendLabel, &$map)
{
    $newLayer = new MgLayer($layerResourceID, $resourceService);
    //Add the new layer to the map's layer collection
    $newLayer->SetName($layerLegendLabel);
    $newLayer->SetVisible(true);
    $newLayer->SetLegendLabel($layerLegendLabel);
    $newLayer->SetDisplayInLegend(true);
    $layerCollection = $map->GetLayers();
    if (!FindLayer($layerCollection, $layerDef)) {
        //Insertthenewlayeratposition0soitisat
        //thetopofthedrawingorder
        $layerCollection->Insert(0, $newLayer);
    }
    return $newLayer;
}
Example #3
0
 $cred->SetClientIp(GetClientIp());
 $cred->SetClientAgent(GetClientAgent());
 //connect to the site and get a feature service and a resource service instances
 $site = new MgSiteConnection();
 $site->Open($cred);
 $featureSrvc = $site->CreateService(MgServiceType::FeatureService);
 $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
 $dataSourceId = new MgResourceIdentifier($dataSource);
 $layerDefId = new MgResourceIdentifier($layerDef);
 //load the map runtime state and locate the measure layer
 //
 $map = new MgMap();
 $map->Open($resourceSrvc, $mapName);
 $layers = $map->GetLayers();
 $srs = GetMapSrs($map);
 $layer = FindLayer($layers, $layerDef);
 if ($clear) {
     $total = 0;
     if ($layer != null) {
         $layers->Remove($layer);
     }
     if (DataSourceExists($resourceSrvc, $dataSourceId)) {
         ClearDataSource($featureSrvc, $dataSourceId, $featureName);
     }
 } else {
     $srsFactory = new MgCoordinateSystemFactory();
     $srsMap = $srsFactory->Create($srs);
     $srsType = $srsMap->GetType();
     if ($srsType == MgCoordinateSystemType::Geographic) {
         $distance = $srsMap->MeasureGreatCircleDistance($x1, $y1, $x2, $y2);
     } else {