react-google-maps to #react-google-maps/api migration, constant for OverlayType - react-google-maps

My app uses the DrawingManager to draw a polygon.
in react-google-maps, the "window.google" variable makes constants available.
What is proper syntax in "#react-google-map/api" ?
react-google-maps:
<GoogleMap ... >
<DrawingManager
defaultDrawingMode={google.maps.drawing.OverlayType.POLYGON}
...
/>
</GoogleMap>
now (very similar)
#react-google-maps/api:
<GoogleMap ... >
<DrawingManager
drawingMode={google.maps.drawing.OverlayType.POLYGON}
...
/>
</GoogleMap>
Tried many syntax... not working. Get the feeling window.google is explicitely deleted at startup. I guess it is normal but how to get constants ?
I get the message:
Uncaught TypeError: Cannot read property 'OverlayType' of undefined
Thanks a lot for help !

ok, this one was simple, needed to add 'drawing' to libraries prop
<LoadScript
googleMapsApiKey="..."
libraries={["drawing"]}
>
<TheWholeApp />
</LoadScript>
Since that, no issue for
<DrawingManager
drawingMode={google.maps.drawing.OverlayType.POLYGON}
...
/>

Related

Trying to make annotated citation style, getting "Error generating citations and bibliography"

I have a question on some csl code.
I am trying to convert the "nature" style which is available through Zotero to an annotated style which gets the annotation by citing the "Extra" field (similar to APA 7th edition annotated).
I am not familiar with coding in csl so I found out thanks to google that all I had to do is add the line
<text variable="note" display="block"/>
before </layout>
(found this info here: https://forums.zotero.org/discussion/19552/annotated-bibliography-in-mla-or-chicago-style)
I did so and now I am getting the following error when generating the style in Zotero's style editor:
Error generating citations and bibliography:
citeproc-js error: Level mismatch error: wanted bib_first but found bib_other
I already checked my code with the CSL style and locale editor (https://validator.citationstyles.org/) and it gives me no errors. Googling this error message does't give any good results. I am trying to use this style in Microsoft Word once it works.
Here are the last couple of lines of the code (if the line <text variable="note" display="block"/> is removed, then the error is gone):
<text macro="editor"/>
<text macro="volume"/>
<text variable="page"/>
<text macro="issuance"/>
<text macro="access"/>
</group>
<text variable="note" display="block"/>
</layout>
</bibliography>
</style>
I would really appreciate if anyone could help with this. Thanks!
I don't think this is in the specifications, but you can't mix second-field-align in the bibliography settings with display set on individual elements (because they're doing the same type of things, so the CSL processor doesn't know what you actually want to do).
I see you found a solution, but that'll not print the annotations on a new line. If you still want that, go back to
<text variable="note" display="block"/>
But then remove the second-field-align from bibliography, i.e. for Nature, turn it into
<bibliography et-al-min="6" et-al-use-first="1" entry-spacing="0" line-spacing="2">
Ok, I was now able to fix this by replacing the line I added with
<text variable="note" prefix=""/>
There is no error message anymore and the citations look great! I will leave this question up, in case anyone is or will be struggling with the same problem.
I haven't tested this, but I think the problem is that you only used display="block" on a single element under <layout/>. Per https://docs.citationstyles.org/en/1.0.1/specification.html#display, "The display attribute ... may be used to structure individual bibliographic entries into one or more text blocks. If used, all rendering elements should be under the control of a display attribute."
If you want the annotations to appear on a new line, I'd try introducing a new <group display="block">...</group> that encompasses the original content of <layout/> in the bibliography section, followed by <text variable="note" display="block"/>.

GWT property with is-multi-valued already defined

While migrating from GWT 2.7.0 to 2.8.2 I came upon property:
<define-configuration-property name="CssResource.gssDefaultInUiBinder"
is-multi-valued="true" />
If this is left as it is, I get an error: The configuration property named CssResource.gssDefaultInUiBinder is already defined with a different 'is-multi-valued' setting.
Does that mean that I can't set attribute is-multi-valued to already defined property? Why would this work with GWT 2.7.0 then? Can anyone give me an explanation about this attribute? Because I am failing to find one...
Attribute set in GWT resources:
<!-- The default for GSS in UiBinder -->
<define-configuration-property name="CssResource.gssDefaultInUiBinder" is-multi-valued="false" />
gwt/user/src/com/google/gwt/resources/Resources.gwt.xml
Correct - you should not be trying to change is-multi-valued, it doesn't really make any sense. You can't re-define a property or configuration-property after it has been set, you can only set the value.
If you want to turn the gss-in-ui-binder flag on, use this:
<set-configuration-property name="CssResource.gssDefaultInUiBinder" value="true" />
If you want to turn it off, either do nothing, or do this:
<set-configuration-property name="CssResource.gssDefaultInUiBinder" value="false" />

Changing entry point class based on form factor

Im looking to load a different user interface in my GWT application if the user is accessing from a mobile web browser or desktop web browser. I was wondering how I would edit my Application.gwt.xml file change which entry point class is loaded based on the the form factor. I thought it might be something along these lines but i'm kind of just hacking so I was wondering if anyone had any ideas?
<entry-point class="webapp.client.WebAppEntryPoint">
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<entry-point class="webapp.client.MobileAppEntryPoint">
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
Cheers.
Its almost as easy as you describe it -- that is, once you have worked out the formfactor property and how to pick a value for it.
It turns out that when you create an entrypoint and declare it in your module, the compiler uses GWT.create to actually make an instance of it. This leaves it subject to the rebind rules declared in your module. So if both WebAppEntryPoint and MobileAppEntryPoint inherit from some common superclass, you can declare that entrypoint in the module, and a slight varient on the rules you made to trigger them to be selected:
<entry-point class="webapp.client.AbstractAppEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
These rules state: "When GWT tries to start the app, use AbstractEntryPoint (which implements EntryPoint) to do so. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is desktop, give them a WebAppEntryPoint instance. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is mobil, give them a MobileAppEntryPoint instance.
This then leaves the hard part - how do you build the formfactor property, define the possible values, and let the app pick the right one on startup?
To help answer this, lets look at two standard properties that already existing in GWT - locale and user.agent. Useragent detection is managed in the com.google.gwt.useragent.UserAgent module - properties are defined, a way to select a property is listed, and some helpful 'make sure that this wiring worked' bits are added to the app. Possible locales are started in com.google.gwt.i18n.I18N, but are designed to be extended within your own app. There is lots of extra stuff in here as well, defining how to pick which locale should be activated. We'll want to steal the idea of pre-defining the possible formfactors from user.agent, and will want the idea of reading the right formfactor from the locale code.
First, define the property.
<define-property name="formfactor" values="desktop, mobile" />
In this example, we'll only allow these two possible values - in reality, you might want desktop (i.e. large and mouse/keyboard), tablet (large and touch), phone (small and touch), or some other variation on this.
Next, decide how to read the right property value. There are two basic ways to do this - via a simple snippet of javascript, written in your module file, and by writing a class that generates JavaScript, based on some configuration settings. I'm going to go with the simplest one first, and let you work out how to actually detect this detail in javascript (update the question or comment if you can clarify further what you have/need/expect):
<!-- borrowing/adapting from
http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties -->
<property-provider name="formfactor"><![CDATA[
{
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('android') != -1) { return 'mobile'; }
if (ua.indexOf('iphone') != -1) { return 'mobile'; }
return 'desktop';
}
]]></property-provider>
Again, this goes in the module, and defines some simple JavaScript to pick the value for formfactor - if the useragent contains the string 'android' or 'iphone', activate the mobile value, otherwise activate desktop. This code will be placed in your .nocache.js file, and used to pick the right permutation (with the right entrypoint, as defined above).
Apart from Colin's detailed answer you might have a look at GWT's standard example for mobilewebapp - http://code.google.com/p/google-web-toolkit/source/browse/#svn%2Ftrunk%2Fsamples%2Fmobilewebapp
The example FormFactor.gwt.xml - http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/FormFactor.gwt.xml
You can use replace with
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.WebAppEntryPoint" />
<any>
<when-property-is name="formfactor" value="mobile"/>
</any>
</replace-with>
NOTE :i am not tried with entry point class ..but working fine for some Widget classes
For details refer Gwt differed binding
SOLVED:
Okay, thanks to everyone who replied. I used a little bit of everyones answer to get to the solution! Firstly I followed SSRs and had a look at the example FormFactor.gwt.xml file. I copied this into my project and referred to it in my App.gwt.xml file. I then followed Colins and added the following code to my App.gwt.xml file in order to load a different EntryPoint based upon form factor:
<entry-point class="webapp.client.AbstractEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</replace-with>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</replace-with>

jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'

I meet the following problem
I am using AlloyUI to implement a portlet in Liferay
with the following code
<liferay-ui:search-container-row
className="com.handysoft.tp.model.TradingCategory"
keyProperty="cId"
modelVar="category">
<liferay-ui:search-container-column-text
name="category-name"
value="<%= category.getCName() %>" />
<liferay-ui:search-container-column-jsp
path="/admin/action.jsp"
align="right" />
</liferay-ui:search-container-row>
Portlet still works but I meet the following error
jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'
If I change one small section to
<liferay-ui:search-container-column-text
name="category-name"
property="cName" />
The error happen in with both cName and cId. Nothing is appear, could u help me to solve this
FeinesFabi is right. It seems that Liferay Search container doesn't take the property names which has more than 1 capital letters in it.
For ex. if a property is tClassId then it won't work but tclassId will work fine.
I've had the same problem.
Renaming the primary key from gID to glossarId an re-running the service builder fixed it for me. I don't understand why, though.

Umbraco 4.6 - macros not rendering

I posted this on the Umbraco forum but to no avail, and wondered if the community at large might be able to offer some advice. We are upgrading our site from 4.0.3 to 4.6. I can't deploy it though as the macros aren't rendering - the error states the following about 30 times:
UmbracoPage Aliases must be unique, and element with alias 'data' has already been loaded!
And also says:
System.Web.HttpException: Multiple controls with the same ID 'ctl00$ctl00$ContentPlaceHolderDefault$ctl28' were found. Trace requires that controls have unique IDs.
I tried deleting the contents of my data file but this didn't help.. I also have 22 duplicate 'homepage' templates that Umbraco won't delete (possibly an issue for another post - or it could be related!).
The error message tells you the issue basically:
"Multiple controls with the same ID..." or in potentially no ID
You most likely have two Macros (of same type/alias) on the page and you are not specifying an ID for them.
Example:
<umbraco:Macro Alias="TestMacro" runat="server" />
<umbraco:Macro Alias="TestMacro" runat="server" />
If you want to render the same macro twice on the same page.
Then you must give them a unique ID (see below):
<umbraco:Macro ID="macro1" Alias="TestMacro" runat="server" />
<umbraco:Macro ID="macro2" Alias="TestMacro" runat="server" />