From 26afcb880ff75743abcb627ecf516b6c51a36d08 Mon Sep 17 00:00:00 2001 From: arno Date: Sun, 15 Aug 2010 15:06:40 +0200 Subject: [PATCH] raw mode to display map --- application/controllers/ErrorController.php | 7 +- application/controllers/IdxController.php | 45 +++++++++-- application/controllers/helpers/SyjReset.php | 15 ++++ application/languages/lang_en.po | 84 +++++++++++--------- application/languages/lang_fr.po | 84 +++++++++++--------- application/layouts/scripts/layout.phtml | 12 +-- application/views/scripts/idx/raw.phtml | 11 +++ public/css/syjraw.css | 22 +++++ public/js/syj.js | 6 +- public/js/syjraw.js | 41 ++++++++++ 10 files changed, 229 insertions(+), 98 deletions(-) create mode 100644 application/controllers/helpers/SyjReset.php create mode 100644 application/views/scripts/idx/raw.phtml create mode 100644 public/css/syjraw.css create mode 100644 public/js/syjraw.js diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index db283ab..7e03015 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -10,12 +10,7 @@ class ErrorController extends Zend_Controller_Action } public function init() { - $this->view->jslocales = null; - $this->view->headScript()->exchangeArray(array()); - $this->view->headLink()->exchangeArray(array()); - $this->view->headTitle()->exchangeArray(array()); - $this->view->headStyle()->exchangeArray(array()); - + $this->_helper->SyjReset->resetPlaceHolders(); $this->view->headLink()->appendStylesheet('css/generic.css'); $this->view->headLink()->appendStylesheet('css/error.css'); } diff --git a/application/controllers/IdxController.php b/application/controllers/IdxController.php index d3c4bcb..0817fe6 100644 --- a/application/controllers/IdxController.php +++ b/application/controllers/IdxController.php @@ -17,6 +17,27 @@ class IdxController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('css/syj.css'); } + public function rawmode(Syj_Model_Path $path) { + $this->_helper->SyjReset->resetPlaceHolders(); + + $this->view->headLink()->appendStylesheet('css/generic.css'); + $this->view->headLink()->appendStylesheet('css/syjraw.css'); + $this->view->headScript()->appendFile('js/OpenLayers.js'); + $this->view->headScript()->appendFile('js/syjraw.js'); + $this->view->headTitle($path->displayTitle); + + $this->_jsRawLocaleStrings(); + if ($path->creator) { + $this->view->jslocales['geomAttribution'] = + $this->view->translate('route by %s', (string)$path->creator->pseudo); + } + $jsgeom = new phptojs\JsObject('gInitialGeom', array('data' => (string) $path->geom)); + $this->view->headScript()->prependScript((string) $jsgeom); + + $this->view->rawmode = true; + $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/raw.:suffix'); + } + public function indexAction() { $url = $this->getRequest()->getUserParam('url'); @@ -35,13 +56,18 @@ class IdxController extends Zend_Controller_Action throw new Syj_Exception_NotFound('Not Found', 404); } } - $geomform->setAction('path/' . (string)$path->id . '/update'); + + if ($this->getRequest()->getQuery('format') == 'raw') { + $this->rawmode($path); + return; + } + $title = $path->displayTitle; $this->view->path = $path; - $geomform->geom_title->setValue($path->title); - $loginform->login_geom_id->setValue((string)$path->id); $jsgeom = new phptojs\JsObject('gInitialGeom', array('data' => (string) $path->geom)); $this->view->headScript()->prependScript((string) $jsgeom); + $loginform->login_geom_id->setValue((string)$path->id); + $geomform->geom_title->setValue($path->title); } else { $geomform->setAction('path'); $extent = new phptojs\JsObject('gMaxExtent', $this->_helper->syjGeoip($this->getRequest()->getClientIp(true))); @@ -51,6 +77,10 @@ class IdxController extends Zend_Controller_Action $this->_jsLoggedInfo(isset($url) ? $path: null); $this->_jsLocaleStrings(); + if (isset ($url) and $path->creator) { + $this->view->jslocales['geomAttribution'] = + $this->view->translate('route by %s', (string)$path->creator->pseudo); + } $this->view->headTitle($title); $this->view->geomform = $geomform; $this->view->loginform = $loginform; @@ -71,9 +101,6 @@ class IdxController extends Zend_Controller_Action if (isset($path)) { $loggedinfo->iscreator = $path->isCreator($user); - if ($path->creator) { - $loggedinfo->creatorname = $this->view->escape((string)$path->creator->pseudo); - } $loggedinfo->pathid = (string)$path->id; } else { $loggedinfo->iscreator = true; @@ -82,6 +109,12 @@ class IdxController extends Zend_Controller_Action $this->view->headScript()->prependScript((string) $loggedinfo); } + protected function _jsRawLocaleStrings() { + $this->view->jslocales = array( + 'osmAttribution' => __("Map by OpenStreetMap"), + ); + } + protected function _jsLocaleStrings() { $this->view->jslocales = array( 'saveSuccess' => __("save took place successfully"), diff --git a/application/controllers/helpers/SyjReset.php b/application/controllers/helpers/SyjReset.php new file mode 100644 index 0000000..15a138e --- /dev/null +++ b/application/controllers/helpers/SyjReset.php @@ -0,0 +1,15 @@ +getActionController(); + $controller->view->jslocales = null; + $controller->view->headScript()->exchangeArray(array()); + $controller->view->headLink()->exchangeArray(array()); + $controller->view->headTitle()->exchangeArray(array()); + $controller->view->headStyle()->exchangeArray(array()); + } +} diff --git a/application/languages/lang_en.po b/application/languages/lang_en.po index 092d66b..6e87cc9 100644 --- a/application/languages/lang_en.po +++ b/application/languages/lang_en.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: syj\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-08-13 15:47+0200\n" +"POT-Creation-Date: 2010-08-15 15:04+0200\n" "PO-Revision-Date: \n" "Last-Translator: arno \n" "Language-Team: arno \n" @@ -45,6 +45,7 @@ msgid "Email was send successfully" msgstr "Email was send successfully" #: application/views/scripts/idx/index.phtml:8 +#: application/views/scripts/idx/raw.phtml:8 #: application/views/scripts/list/index.phtml:8 msgid "SYJ needs javascript. Please activate scripts in your browser." msgstr "SYJ needs javascript. Please activate scripts in your browser." @@ -62,12 +63,12 @@ msgid "When you have finished a path, press \"save\", button." msgstr "When you have finished a path, press \"save\", button." #: application/views/scripts/idx/index.phtml:26 -#: application/controllers/IdxController.php:112 +#: application/controllers/IdxController.php:146 msgid "duplicate" msgstr "duplicate" #: application/views/scripts/idx/index.phtml:28 -#: application/controllers/IdxController.php:110 +#: application/controllers/IdxController.php:144 msgid "edit" msgstr "edit" @@ -77,7 +78,7 @@ msgstr "start a route" #: application/views/scripts/idx/index.phtml:43 #: application/controllers/LoginController.php:8 -#: application/layouts/scripts/footer.phtml:72 +#: application/layouts/scripts/footer.phtml:74 #: application/forms/Login.php:26 msgid "login" msgstr "login" @@ -116,7 +117,7 @@ msgid "Sources of the software running the website are publicly available under a agpl license. The map used to display the routes comes from openstreetmap." #: application/views/scripts/newpwd/success.phtml:4 -#: application/controllers/IdxController.php:103 +#: application/controllers/IdxController.php:137 msgid "A link to reset your password has been emailed to you" msgstr "A link to reset your password has been emailed to you" @@ -198,7 +199,7 @@ msgid "delete" msgstr "delete" #: application/views/helpers/LogoutLink.php:10 -#: application/layouts/scripts/footer.phtml:65 +#: application/layouts/scripts/footer.phtml:67 msgid "logout" msgstr "logout" @@ -360,8 +361,8 @@ msgstr "" "\n" "Syj team" -#: application/controllers/LoginController.php:101 -#: application/controllers/IdxController.php:93 +#: application/controllers/LoginController.php:100 +#: application/controllers/IdxController.php:127 msgid "you must enter a login name" msgstr "you must enter a login name" @@ -410,19 +411,19 @@ msgstr "Value is required and can't be empty" msgid "Invalid email" msgstr "Invalid email" -#: application/controllers/ErrorController.php:61 +#: application/controllers/ErrorController.php:56 msgid "Oups, something went wrong" msgstr "Oups, something went wrong" #: application/controllers/TermsofuseController.php:12 -#: application/layouts/scripts/footer.phtml:85 +#: application/layouts/scripts/footer.phtml:87 #: application/forms/Geom.php:24 #: application/forms/User.php:43 msgid "terms of use" msgstr "terms of use" #: application/controllers/ListController.php:18 -#: application/layouts/scripts/footer.phtml:51 +#: application/layouts/scripts/footer.phtml:53 msgid "my routes" msgstr "my routes" @@ -431,27 +432,27 @@ msgid "There is no undo. Delete this route definitively ?" msgstr "There is no undo. Delete this route definitively ?" #: application/controllers/ListController.php:36 -#: application/controllers/IdxController.php:90 +#: application/controllers/IdxController.php:124 msgid "server could not be reached" msgstr "server could not be reached" #: application/controllers/ListController.php:37 -#: application/controllers/IdxController.php:87 +#: application/controllers/IdxController.php:121 msgid "server did not understood request. That's probably caused by a bug in SYJ" msgstr "server did not understood request. That's probably caused by a bug in SYJ" #: application/controllers/ListController.php:38 -#: application/controllers/IdxController.php:88 +#: application/controllers/IdxController.php:122 msgid "route not referenced on the server. It has probably been deleted." msgstr "route not referenced on the server. It has probably been deleted." #: application/controllers/ListController.php:39 -#: application/controllers/IdxController.php:91 +#: application/controllers/IdxController.php:125 msgid "there was a server error" msgstr "there was a server error" #: application/controllers/ListController.php:40 -#: application/controllers/IdxController.php:92 +#: application/controllers/IdxController.php:126 msgid "there was an unknown error" msgstr "there was an unknown error" @@ -469,12 +470,12 @@ msgid "Wrong password" msgstr "Wrong password" #: application/controllers/AccountController.php:44 -#: application/controllers/IdxController.php:101 +#: application/controllers/IdxController.php:135 msgid "an user is already registered with this email" msgstr "an user is already registered with this email" #: application/controllers/AccountController.php:72 -#: application/controllers/IdxController.php:97 +#: application/controllers/IdxController.php:131 #: application/forms/Account.php:40 msgid "Password do not match" msgstr "Password do not match" @@ -490,71 +491,78 @@ msgstr "At least %d characters" msgid "You have made no change" msgstr "You have made no change" -#: application/controllers/IdxController.php:86 +#: application/controllers/IdxController.php:32 +#: application/controllers/IdxController.php:82 +#, php-format +msgid "route by %s" +msgstr "route by %s" + +#: application/controllers/IdxController.php:114 +#: application/controllers/IdxController.php:140 +msgid "Map by OpenStreetMap" +msgstr "Map by OpenStreetMap" + +#: application/controllers/IdxController.php:120 msgid "save took place successfully" msgstr "save took place successfully" -#: application/controllers/IdxController.php:89 +#: application/controllers/IdxController.php:123 msgid "similar path seems to already exist. Please do not create two exactly identical paths" msgstr "similar path seems to already exist. Please do not create two exactly identical paths" -#: application/controllers/IdxController.php:94 +#: application/controllers/IdxController.php:128 msgid "Login correct" msgstr "Login correct" -#: application/controllers/IdxController.php:95 +#: application/controllers/IdxController.php:129 msgid "Wrong login/password" msgstr "Wrong login/password" -#: application/controllers/IdxController.php:96 +#: application/controllers/IdxController.php:130 msgid "you must enter a password" msgstr "you must enter a password" -#: application/controllers/IdxController.php:98 +#: application/controllers/IdxController.php:132 msgid "You must accept terms of use" msgstr "You must accept terms of use" -#: application/controllers/IdxController.php:99 +#: application/controllers/IdxController.php:133 msgid "you must enter an email" msgstr "you must enter an email" -#: application/controllers/IdxController.php:100 +#: application/controllers/IdxController.php:134 msgid "invalid email" msgstr "invalid email" -#: application/controllers/IdxController.php:102 +#: application/controllers/IdxController.php:136 msgid "Account created" msgstr "Account created" -#: application/controllers/IdxController.php:104 +#: application/controllers/IdxController.php:138 msgid "Now, you can retry to save" msgstr "Now, you can retry to save" -#: application/controllers/IdxController.php:105 +#: application/controllers/IdxController.php:139 msgid "route by" msgstr "route by" -#: application/controllers/IdxController.php:106 -msgid "Map by OpenStreetMap" -msgstr "Map by OpenStreetMap" - -#: application/controllers/IdxController.php:107 +#: application/controllers/IdxController.php:141 msgid "checking availibilty" msgstr "checking availibilty" -#: application/controllers/IdxController.php:108 +#: application/controllers/IdxController.php:142 msgid "available pseudo" msgstr "available pseudo" -#: application/controllers/IdxController.php:109 +#: application/controllers/IdxController.php:143 msgid "unavailable pseudo" msgstr "unavailable pseudo" -#: application/controllers/IdxController.php:111 +#: application/controllers/IdxController.php:145 msgid "create" msgstr "create" -#: application/controllers/IdxController.php:113 +#: application/controllers/IdxController.php:147 msgid "You have an unsaved route" msgstr "You have an unsaved route" diff --git a/application/languages/lang_fr.po b/application/languages/lang_fr.po index e593e8f..cc221a9 100644 --- a/application/languages/lang_fr.po +++ b/application/languages/lang_fr.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: syj\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-08-13 15:47+0200\n" +"POT-Creation-Date: 2010-08-15 15:04+0200\n" "PO-Revision-Date: \n" "Last-Translator: arno \n" "Language-Team: arno \n" @@ -45,6 +45,7 @@ msgid "Email was send successfully" msgstr "L'email a été envoyé avec succès" #: application/views/scripts/idx/index.phtml:8 +#: application/views/scripts/idx/raw.phtml:8 #: application/views/scripts/list/index.phtml:8 msgid "SYJ needs javascript. Please activate scripts in your browser." msgstr "SYJ a besoin de javascript pour fonctionner. Veuillez activer les scripts dans votre navigateur." @@ -62,12 +63,12 @@ msgid "When you have finished a path, press \"save\", button." msgstr "Lorsque vous avez fini votre tracé, pressez le bouton \"enregistrer\"." #: application/views/scripts/idx/index.phtml:26 -#: application/controllers/IdxController.php:112 +#: application/controllers/IdxController.php:146 msgid "duplicate" msgstr "dupliquer" #: application/views/scripts/idx/index.phtml:28 -#: application/controllers/IdxController.php:110 +#: application/controllers/IdxController.php:144 msgid "edit" msgstr "modifier" @@ -77,7 +78,7 @@ msgstr "commencer un itinéraire" #: application/views/scripts/idx/index.phtml:43 #: application/controllers/LoginController.php:8 -#: application/layouts/scripts/footer.phtml:72 +#: application/layouts/scripts/footer.phtml:74 #: application/forms/Login.php:26 msgid "login" msgstr "connexion" @@ -116,7 +117,7 @@ msgid "Sources of the software running the website are disponibles publiquement sous une licence agpl. La carte utilisée pour l'affichage des itinéraires vient d'openstreetmap." #: application/views/scripts/newpwd/success.phtml:4 -#: application/controllers/IdxController.php:103 +#: application/controllers/IdxController.php:137 msgid "A link to reset your password has been emailed to you" msgstr "Un email contenant un lien pour réinitialiser votre mot de passe vous a été envoyé" @@ -198,7 +199,7 @@ msgid "delete" msgstr "supprimer" #: application/views/helpers/LogoutLink.php:10 -#: application/layouts/scripts/footer.phtml:65 +#: application/layouts/scripts/footer.phtml:67 msgid "logout" msgstr "déconnexion" @@ -362,8 +363,8 @@ msgstr "" "\n" "L'équipe de Syj" -#: application/controllers/LoginController.php:101 -#: application/controllers/IdxController.php:93 +#: application/controllers/LoginController.php:100 +#: application/controllers/IdxController.php:127 msgid "you must enter a login name" msgstr "vous devez entrer un nom d'utilisateur" @@ -412,19 +413,19 @@ msgstr "Le champ est requis, et ne doit pas être vide" msgid "Invalid email" msgstr "Email invalide" -#: application/controllers/ErrorController.php:61 +#: application/controllers/ErrorController.php:56 msgid "Oups, something went wrong" msgstr "Oups, il y a eu un souci" #: application/controllers/TermsofuseController.php:12 -#: application/layouts/scripts/footer.phtml:85 +#: application/layouts/scripts/footer.phtml:87 #: application/forms/Geom.php:24 #: application/forms/User.php:43 msgid "terms of use" msgstr "conditions d'utilisation" #: application/controllers/ListController.php:18 -#: application/layouts/scripts/footer.phtml:51 +#: application/layouts/scripts/footer.phtml:53 msgid "my routes" msgstr "mes itinéraires" @@ -433,27 +434,27 @@ msgid "There is no undo. Delete this route definitively ?" msgstr "Vous ne pourrez pas annuler. Supprimer l'itinéraire définitivement ?" #: application/controllers/ListController.php:36 -#: application/controllers/IdxController.php:90 +#: application/controllers/IdxController.php:124 msgid "server could not be reached" msgstr "serveur inaccessible" #: application/controllers/ListController.php:37 -#: application/controllers/IdxController.php:87 +#: application/controllers/IdxController.php:121 msgid "server did not understood request. That's probably caused by a bug in SYJ" msgstr "Le serveur n'a pas compris la requête. Il s'agit probablement d'un bug dans SYJ" #: application/controllers/ListController.php:38 -#: application/controllers/IdxController.php:88 +#: application/controllers/IdxController.php:122 msgid "route not referenced on the server. It has probably been deleted." msgstr "chemin non référencé sur le serveur. Il a probablement été supprimé." #: application/controllers/ListController.php:39 -#: application/controllers/IdxController.php:91 +#: application/controllers/IdxController.php:125 msgid "there was a server error" msgstr "Il s'est produit une erreur serveur" #: application/controllers/ListController.php:40 -#: application/controllers/IdxController.php:92 +#: application/controllers/IdxController.php:126 msgid "there was an unknown error" msgstr "Il s'est produit une erreur inconnue" @@ -471,12 +472,12 @@ msgid "Wrong password" msgstr "Mauvais mot de passe" #: application/controllers/AccountController.php:44 -#: application/controllers/IdxController.php:101 +#: application/controllers/IdxController.php:135 msgid "an user is already registered with this email" msgstr "il y'a déjà un utilisateur enregistré avec cet email" #: application/controllers/AccountController.php:72 -#: application/controllers/IdxController.php:97 +#: application/controllers/IdxController.php:131 #: application/forms/Account.php:40 msgid "Password do not match" msgstr "Les mots de passe ne correspondent pas" @@ -492,71 +493,78 @@ msgstr "Au moins %d caractères" msgid "You have made no change" msgstr "Vous n'avez fait aucun changement" -#: application/controllers/IdxController.php:86 +#: application/controllers/IdxController.php:32 +#: application/controllers/IdxController.php:82 +#, php-format +msgid "route by %s" +msgstr "tracé par %s" + +#: application/controllers/IdxController.php:114 +#: application/controllers/IdxController.php:140 +msgid "Map by OpenStreetMap" +msgstr "Carte par OpenStreetMap" + +#: application/controllers/IdxController.php:120 msgid "save took place successfully" msgstr "La sauvegarde s'est déroulée correctement" -#: application/controllers/IdxController.php:89 +#: application/controllers/IdxController.php:123 msgid "similar path seems to already exist. Please do not create two exactly identical paths" msgstr "Il semble qu'il y ait déjà un chemin similaire. Veuillez ne pas créer deux chemins exactement identiques" -#: application/controllers/IdxController.php:94 +#: application/controllers/IdxController.php:128 msgid "Login correct" msgstr "Vous êtes connectés" -#: application/controllers/IdxController.php:95 +#: application/controllers/IdxController.php:129 msgid "Wrong login/password" msgstr "Mauvais nom d'utilisateur ou mot de passe" -#: application/controllers/IdxController.php:96 +#: application/controllers/IdxController.php:130 msgid "you must enter a password" msgstr "vous devez entrer un mot de passe" -#: application/controllers/IdxController.php:98 +#: application/controllers/IdxController.php:132 msgid "You must accept terms of use" msgstr "Vous devez accepter les conditions d'utilisation" -#: application/controllers/IdxController.php:99 +#: application/controllers/IdxController.php:133 msgid "you must enter an email" msgstr "vous devez entrer un email" -#: application/controllers/IdxController.php:100 +#: application/controllers/IdxController.php:134 msgid "invalid email" msgstr "email invalide" -#: application/controllers/IdxController.php:102 +#: application/controllers/IdxController.php:136 msgid "Account created" msgstr "Compte créé" -#: application/controllers/IdxController.php:104 +#: application/controllers/IdxController.php:138 msgid "Now, you can retry to save" msgstr "Maintenant, vous pouvez réessayer de sauvegarder" -#: application/controllers/IdxController.php:105 +#: application/controllers/IdxController.php:139 msgid "route by" msgstr "tracé par" -#: application/controllers/IdxController.php:106 -msgid "Map by OpenStreetMap" -msgstr "Carte par OpenStreetMap" - -#: application/controllers/IdxController.php:107 +#: application/controllers/IdxController.php:141 msgid "checking availibilty" msgstr "vérification de la disponibilité" -#: application/controllers/IdxController.php:108 +#: application/controllers/IdxController.php:142 msgid "available pseudo" msgstr "pseudo disponible" -#: application/controllers/IdxController.php:109 +#: application/controllers/IdxController.php:143 msgid "unavailable pseudo" msgstr "pseudo non disponible" -#: application/controllers/IdxController.php:111 +#: application/controllers/IdxController.php:145 msgid "create" msgstr "créér" -#: application/controllers/IdxController.php:113 +#: application/controllers/IdxController.php:147 msgid "You have an unsaved route" msgstr "Vous avez un itinéraire non sauvegardé" diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index 5736ac1..dfbbaf5 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -27,15 +27,15 @@ render('header.phtml'); -?> + if (!$this->rawmode) { + echo $this->render('header.phtml'); + } -layout()->content; -?> -render('footer.phtml'); + if (!$this->rawmode) { + echo $this->render('footer.phtml'); + } ?> diff --git a/application/views/scripts/idx/raw.phtml b/application/views/scripts/idx/raw.phtml new file mode 100644 index 0000000..d6e2d14 --- /dev/null +++ b/application/views/scripts/idx/raw.phtml @@ -0,0 +1,11 @@ + + +
diff --git a/public/css/syjraw.css b/public/css/syjraw.css new file mode 100644 index 0000000..053c250 --- /dev/null +++ b/public/css/syjraw.css @@ -0,0 +1,22 @@ +/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier, + and is published under the AGPL license. */ +body, html { + margin: 0; padding: 0; + width: 100%; + height: 100%; +} + +/* + * map rules + */ +#map { + position: absolute; + top: 0; left: 0; right: 0; bottom: 0; + *width: 100%; + *height: 100%; +} + +.olControlAttribution { + bottom: 0.5em; + left: 0.5em; +} diff --git a/public/js/syj.js b/public/js/syj.js index 9114646..923e93d 100644 --- a/public/js/syj.js +++ b/public/js/syj.js @@ -227,10 +227,8 @@ var SYJView = { layerOptions = {format: OpenLayers.Format.WKT, projection: WGS84, - styleMap: styleMap.view}; - if (gLoggedInfo.creatorname) { - layerOptions.attribution = SyjStrings.routeBy + ' ' + '' + gLoggedInfo.creatorname + ''; - } + styleMap: styleMap.view, + attribution: SyjStrings.geomAttribution }; this.viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions); this.map.addLayers([baseLayer, this.viewLayer]); diff --git a/public/js/syjraw.js b/public/js/syjraw.js new file mode 100644 index 0000000..ec783f4 --- /dev/null +++ b/public/js/syjraw.js @@ -0,0 +1,41 @@ +var WGS84 = new OpenLayers.Projection("EPSG:4326"); +var Mercator = new OpenLayers.Projection("EPSG:900913"); + +var styleMap = { + view: new OpenLayers.StyleMap({ + "default": new OpenLayers.Style({ + strokeColor: "blue", + strokeWidth: 5, + strokeOpacity: 0.7 + }) + }) +}; + +function init() { + var map = new OpenLayers.Map('map', { + controls: [ new OpenLayers.Control.Attribution() ], + theme: null}), + + baseLayer = new OpenLayers.Layer.OSM("OSM", null, { attribution: SyjStrings.osmAttribution }), + + layerOptions = {format: OpenLayers.Format.WKT, + projection: WGS84, + styleMap: styleMap.view, + attribution: SyjStrings.geomAttribution }, + + viewLayer = new OpenLayers.Layer.Vector("View Layer", layerOptions), + wkt = new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 }); + + map.addLayers([baseLayer, viewLayer]); + viewLayer.addFeatures([wkt.read(gInitialGeom.data)]); + extent = viewLayer.getDataExtent(); + map.updateSize(); + map.zoomToExtent(extent); + +} + +if (window.addEventListener) { + window.addEventListener("load", init, false); +} else { + window.attachEvent("onload", init); +} -- 2.39.2