public static function factory($params, MapDevice $mapDevice) { $baseURL = null; $baseURLParam = 'STATIC_MAP_BASE_URL'; if (isset($params['JS_MAP_CLASS']) && $mapDevice->pageSupportsDynamicMap()) { $imageClass = $params['JS_MAP_CLASS']; $baseURLParam = 'DYNAMIC_MAP_BASE_URL'; } elseif (isset($params['STATIC_MAP_CLASS'])) { $imageClass = $params['STATIC_MAP_CLASS']; } elseif ($mapDevice->pageSupportsDynamicMap()) { $imageClass = self::$DEFAULT_JS_MAP_CLASS; $baseURLParam = 'DYNAMIC_MAP_BASE_URL'; } else { $imageClass = self::$DEFAULT_STATIC_MAP_CLASS; } if (isset($params[$baseURLParam])) { $baseURL = $params[$baseURLParam]; } if ($baseURL !== null) { $controller = new $imageClass($baseURL); } else { $controller = new $imageClass(); } $controller->init(); return $controller; }
public static function basemapClassForDevice(MapDevice $mapDevice, $params = array()) { $isStatic = false; if (isset($params['JS_MAP_CLASS']) && $mapDevice->pageSupportsDynamicMap()) { $mapClass = $params['JS_MAP_CLASS']; } elseif (isset($params['STATIC_MAP_CLASS'])) { $mapClass = $params['STATIC_MAP_CLASS']; $isStatic = true; } elseif ($mapDevice->pageSupportsDynamicMap()) { $mapClass = self::$DEFAULT_JS_MAP_CLASS; } else { $mapClass = self::$DEFAULT_STATIC_MAP_CLASS; $isStatic = true; } return array($mapClass, $isStatic); }
private function initializeMap(MapDataController $dataController, MapFeature $feature, $fullscreen=FALSE) { $MapDevice = new MapDevice($this->pagetype, $this->platform); $style = $feature->getStyle(); $geometries = array(); $geometries[] = $feature->getGeometry(); // zoom if (isset($this->args['zoom'])) { $zoomLevel = $this->args['zoom']; } else { $zoomLevel = $dataController->getDefaultZoomLevel(); } if ($MapDevice->pageSupportsDynamicMap() && $dataController->supportsDynamicMap()) { $imgController = $dataController->getDynamicMapController(); } else { $imgController = $dataController->getStaticMapController(); } if ($imgController->supportsProjections()) { $imgController->setDataProjection($dataController->getProjection()); } else { $dataProjection = $dataController->getProjection(); $outputProjection = $imgController->getMapProjection(); if ($dataProjection != $outputProjection) { $projector = new MapProjector(); $projector->setSrcProj($dataProjection); $projector->setDstProj($outputProjection); foreach ($geometries as $i => $geometry) { $geometries[$i] = $projector->projectGeometry($geometry); } } } if (isset($this->args['lat'], $this->args['lon'])) { array_unshift($geometries, new EmptyMapPoint($this->args['lat'], $this->args['lon'])); } // center if (isset($this->args['center'])) { $latlon = explode(",", $this->args['center']); $center = array('lat' => $latlon[0], 'lon' => $latlon[1]); } else { $center = $geometries[0]->getCenterCoordinate(); } $imgController->setCenter($center); $imgController->setZoomLevel($zoomLevel); foreach ($geometries as $i => $geometry) { if ($geometry instanceof MapPolygon) { if ($imgController->canAddPolygons()) { $imgController->addPolygon($geometry->getRings(), $style); } } elseif ($geometry instanceof MapPolyline) { if ($imgController->canAddPaths()) { $imgController->addPath($geometry->getPoints(), $style); } } else { if ($imgController->canAddAnnotations()) { $imgController->addAnnotation($geometry->getCenterCoordinate(), $style, $feature->getTitle()); } } } if (!$fullscreen) { $this->assign('fullscreenURL', $this->buildBreadcrumbURL('fullscreen', $this->args, false)); if ($imgController->isStatic()) { list($imageWidth, $imageHeight) = $MapDevice->staticMapImageDimensions(); } else { list($imageWidth, $imageHeight) = $MapDevice->dynamicMapImageDimensions(); $this->addInlineJavascriptFooter("\n hideMapTabChildren();\n"); } } else { $this->assign('detailURL', $this->buildBreadcrumbURL('detail', $this->args, false)); if ($imgController->isStatic()) { list($imageWidth, $imageHeight) = $MapDevice->staticMapImageDimensions(); } else { list($imageWidth, $imageHeight) = $MapDevice->fullscreenMapImageDimensions(); $this->addJavascriptFullscreenDynamicMap(); } } $this->assign('fullscreen', $fullscreen); $this->assign('isStatic', $imgController->isStatic()); $this->initializeMapElements('mapimage', $imgController, $imageWidth, $imageHeight); // call the function that updates the image size if ($fullscreen && $imgController->isStatic()) { $this->addJavascriptFullscreenStaticMap(); } }