Example #1
0
 protected function getCurrentScale()
 {
     if ($this->unitsPerMeter === null) {
         $this->unitsPerMeter = self::NO_PROJECTION;
         $projRep = new MapProjection($this->mapProjection);
         if (!$projRep->isGeographic()) {
             $unitsPerMeter = $projRep->getUnitsPerMeter();
             if ($unitsPerMeter) {
                 $this->unitsPerMeter = $unitsPerMeter;
             }
         }
     }
     if ($this->unitsPerMeter != self::NO_PROJECTION) {
         $metersPerPixel = $this->getHorizontalRange() / $this->imageWidth / $this->unitsPerMeter;
         return $metersPerPixel / self::LIFE_SIZE_METERS_PER_PIXEL;
     } else {
         $range = $this->getHorizontalRange();
         $zoomLevel = ceil(log(360 / $range, 2));
         return oldPixelScaleForZoomLevel($zoomLevel);
     }
 }
Example #2
0
 function getFooterScript()
 {
     $zoomLevel = $this->zoomLevel;
     $targetScale = oldPixelScaleForZoomLevel($zoomLevel);
     if ($this->levelsOfDetail) {
         // TODO: if all zoom levels fail this test, the zoom level will
         // revert to the internal powers-of-two style zoom level i.e. not
         // necessarily what we want
         foreach ($this->levelsOfDetail as $levelData) {
             if ($levelData['scale'] < $targetScale) {
                 break;
             } else {
                 $zoomLevel = $levelData['level'];
             }
         }
     }
     $moreLayers = array();
     foreach ($this->moreLayers as $layer) {
         $moreLayers[] = '"' . $layer . '"';
     }
     $footer = $this->prepareJavascriptTemplate('ArcGISJSMapFooter');
     $footer->setValues(array('___WKID___' => $this->mapProjection, '___MAPELEMENT___' => $this->mapElement, '___IMAGE_WIDTH___' => $this->imageWidth, '___IMAGE_HEIGHT___' => $this->imageHeight, '___ZOOMLEVEL___' => $zoomLevel, '___BASE_URL___' => $this->baseURL, '___MORE_LAYER_SCRIPT___' => '[' . implode(',', $moreLayers) . ']', '___MARKER_SCRIPT___' => $this->getMarkerJS(), '___POLYGON_SCRIPT___' => $this->getPolygonJS(), '___PATH_SCRIPT___' => $this->getPathJS()));
     if ($this->mapProjector) {
         $xy = $this->mapProjector->projectPoint($this->center);
         list($x, $y) = MapProjector::getXYFromPoint($xy);
         $footer->setValues(array('___X___' => $x, '___Y___' => $y));
     } else {
         $footer->setValues(array('___X___' => $this->center['lon'], '___Y___' => $this->center['lat']));
     }
     return $footer->getScript();
 }
Example #3
0
    function getFooterScript()
    {
        // put dojo stuff in the footer since the header script
        // gets loaded before the included script
        $zoomLevel = $this->zoomLevel;
        $targetScale = oldPixelScaleForZoomLevel($zoomLevel);
        if ($this->levelsOfDetail) {
            foreach ($this->levelsOfDetail as $levelData) {
                if ($levelData['scale'] < $targetScale) {
                    break;
                } else {
                    $zoomLevel = $levelData['level'];
                }
            }
        }
        $moreLayersJS = '';
        foreach ($this->moreLayers as $anotherLayer) {
            $moreLayersJS .= <<<JS
    map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("{$anotherLayer}", 1.0));
JS;
        }
        $footer = $this->prepareJavascriptTemplate('ArcGISJSMapFooter');
        $footer->setValues(array('___FULL_URL_PREFIX___' => FULL_URL_PREFIX, '___API_URL___' => FULL_URL_BASE . API_URL_PREFIX . "/map/projectPoint", '___WKID___' => $this->mapProjection, '___MAPELEMENT___' => $this->mapElement, '___IMAGE_WIDTH___' => $this->imageWidth, '___IMAGE_HEIGHT___' => $this->imageHeight, '___ZOOMLEVEL___' => $zoomLevel, '___BASE_URL___' => $this->baseURL, '___MORE_LAYER_SCRIPT___' => $moreLayersJS, '___MARKER_SCRIPT___' => $this->getMarkerJS(), '___POLYGON_SCRIPT___' => $this->getPolygonJS(), '___PATH_SCRIPT___' => $this->getPathJS()));
        if ($this->mapProjector) {
            $xy = $this->mapProjector->projectPoint($this->center);
            list($x, $y) = MapProjector::getXYFromPoint($xy);
            $footer->setValues(array('___X___' => $x, '___Y___' => $y));
        } else {
            $footer->setValues(array('___X___' => $this->center['lon'], '___Y___' => $this->center['lat']));
        }
        return $footer->getScript();
    }