open layers 3 - Namespace "ol" already declared error on startup - openlayers-3

I am using instructions from here on how to get started with open layers and I got the error: Namespace "ol" already declared - source ol-debug.js and the error
this.Va is not a function - source ol.js
I am pretty sure I have included the ol.js, ol-debug.js and ol.css files properly in my index.html.
Link to open layers js and css files.
This is the relevant part from ol-debug.js file -
/**
* Defines a namespace in Closure.
*
* A namespace may only be defined once in a codebase. It may be defined using
* goog.provide() or goog.module().
*
* The presence of one or more goog.provide() calls in a file indicates
* that the file defines the given objects/namespaces.
* Provided symbols must not be null or undefined.
*
* In addition, goog.provide() creates the object stubs for a namespace
* (for example, goog.provide("goog.foo.bar") will create the object
* goog.foo.bar if it does not already exist).
*
* Build tools also scan for provide/require/module statements
* to discern dependencies, build dependency files (see deps.js), etc.
*
* #see goog.require
* #see goog.module
* #param {string} name Namespace provided by this file in the form
* "goog.package.part".
*/
goog.provide = function(name) {
if (goog.isInModuleLoader_()) {
throw Error('goog.provide can not be used within a goog.module.');
}
if (!COMPILED) {
// Ensure that the same namespace isn't provided twice.
// A goog.module/goog.provide maps a goog.require to a specific file
if (goog.isProvided_(name)) {
throw Error('Namespace "' + name + '" already declared.');
}
}
goog.constructNamespace_(name);
};

You need to declare either ol.js or ol-debug.js, not both of them. The error is coming from the fact that you're declaring both of them and it is creating a namespace conflict.

Related

Symfony 4.0 Translator class not injected to controller

I got a problem in new symfony 4.
<?php
namespace App\Controller;
use App\Entity\Flight;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use App\Form\FlightType;
use Symfony\Component\Translation\Translator;
use Symfony\Component\HttpFoundation\Request;
/**
* Class DefaultController
* #package App\Controller
*/
class DefaultController extends Controller
{
/**
*
* #Route("/")
* #Route("/{_locale}/", name="homepage", requirements={"_locale" = "%app.locales%"})
*
* #param Translator $translator
* #param Request $request
*
* #return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function index(Translator $translator, Request $request)
{
$translated = $translator->trans('Symfony is great');
Error:
Controller "App\Controller\DefaultController::index()" requires that you provide a value for the "$translator" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.
Configs:
service.yaml
services:
_defaults:
autowire: true
autoconfigure: true
public: false
...
App\Controller\:
autowire: true
resource: '../src/Controller'
tags: ['controller.service_arguments']
translation.yaml
framework:
default_locale: '%locale%'
translator:
paths:
- '%kernel.project_dir%/translations'
fallbacks: ['en']
Whats wrong? Manual here:
http://symfony.com/doc/current/translation.html
Found the answer.
bin/console cache:clear did not clear messages cache. Helped just hard remove var/cache folder.
I have used Action(TranslatorInterface $translator) for inject to controller action (Probably bug in docs)
$translator->trans('id') doesn't work with ids. It work when using trans-unit sourse tag.

Hostname Validator with Annotation Builder

I am currently using the Form Annotation builder with Zend Framework 2 (Latest 2.3.2).
I have a single form validator which does not want to play nice and I cannot find any example documentation on how to make the Hostname validator work properly when allowing local hostnames.
Here is a code snippet of the validator in question:
/**
* #Form\Type("text")
* #Form\Required(false)
* #Form\Options({"label":"name"})
* #Form\Attributes({"id":"name"})
* #Form\Filter({"name":"stringtrim"})
* #Form\Filter({"name":"stringtolower"})
* #Form\Validator({"name":"stringlength", "options":{"min":"1", "max":"254"}, "break_chain_on_failure":"true"})
* #Form\Validator({"name":"hostname", "options":{"allow":"\Zend\Validator\Hostname::ALLOW_LOCAL"}, "break_chain_on_failure":"true"})
* #Form\Validator({"name":"CompanyDns\Validator\DnsName", "break_chain_on_failure":"true"})
*/
public $name;
When the form attempts to validate using a local name I am getting the validators response of:
The input appears to be a local network name but local network names are not allowed
I am following the manual http://framework.zend.com/manual/2.3/en/modules/zend.form.quick-start.html#using-annotations
Any ideas what I am missing or can do to resolve this?
It appears that when using the Annotation Builder additional Hostname::* features do not get passed as one would expect.
So this line:
#Form\Validator({"name":"hostname", "options":{"allow":"\Zend\Validator\Hostname::ALLOW_LOCAL"}, "break_chain_on_failure":"true"})
Should actually read:
#Form\Validator({"name":"hostname", "options":{"allow":"4"}, "break_chain_on_failure":"true"})
If you look at the Hostname Validator class the 4 represents the ALLOW_LOCAL of the validator.
This should resolve the problem for you.

#availability keyword not working in Xcode "alt+click" documentation helper

I'm trying to document my header files and I really like the concept of alt+click documentation helper.
Using code below I can set keywords like #param or #return or #see but unforunately #availability is not being displayed in the proper way.
/**
* Super method for super feature
*
* #param someParameter super cool method parameter
*
* #availability Version 3.0 (and later)
*
* #return void
*/
The question is: how to set availability parameter in documentation helper?
You're looking for #since, not #availability.
For a comprehensive list of commands, see this question.
You need to user NS_AVAILABLE_IOS(5_0) to show the availability.
Here is an example:
/**
Check whether a file at a given URL has a newer timestamp than a given file.
Example usage:
#code
NSURL *url1, *url2;
BOOL isNewer = [FileUtils
isThisFileNewerThanThatFile:url1 thatURL:url2];
#endcode
#param index
The index
#return the results
*/
- (UIImage*)imageForSectionIndex:(NSUInteger)index NS_AVAILABLE_IOS(6_0){
// your implem
}

How to generate truncated Javadoc?

I encountered a problem with Javadoc generation. I would like to create a truncated Javadoc consisting only of specific comments, specifically - test cases (which are described by every #Test annotation), packages and classes, all other information is not needed. Is it possible to limit other elements in Javadoc while generating it without parsing it ?
For example:
/**
* <b>Test case A:</b>
*
* <ol>
* <li>Navigate to main application</li>
* <li>In actions drop-down select value = 'Run'</li>
* <li>Assert that application is running</li>
* </ol>
*
**/
#Test
public void testMainApp() throws IOException {
navigateToMainApp();
selectAndExecute();
Assert.assertEquals("Applications is not running: ", true, status.equals(RUNNING));
}
Thanks in advance!
You can use maven to generate javadocs(http://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html). You will be able to exclude packages and source files for which you do not want to create docs.
Hope this helps.

can't turn of strict checking on include of duplicate constructor class - php 5.3

I have a system where Joomla and Symfony Frameworks work together. In a specific situation I need to include a range of files in Joomla from within Symfony. The problematic Joomla file has a "duplicate constructor" for PHP4 compatibility purposes, like so:
class JObject{
/**
* An array of errors
*
* #var array of error messages or JExceptions objects
* #access protected
* #since 1.0
*/
var $_errors = array();
/**
* A hack to support __construct() on PHP 4
*
* Hint: descendant classes have no PHP4 class_name() constructors,
* so this constructor gets called first and calls the top-layer __construct()
* which (if present) should call parent::__construct()
*
* #access public
* #return Object
* #since 1.5
*/
function JObject()
{
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
/**
* Class constructor, overridden in descendant classes.
*
* #access protected
* #since 1.5
*/
function __construct() {}
When I include this, I get an error
Strict Standards: Redefining already defined constructor
From what I can find on php.net I should be able to turn Strict standards off like this, but it doesn't work:
error_reporting(error_reporting() & (E_ALL ^ E_STRICT));
In your apps/<app name>/config/settings.yml you should be able to set the error_reporting level. Something like:
all:
.settings:
error_reporting: <?php echo (E_ALL | E_STRICT)."\n" ?>

Resources