I see a potential cause of the problem. I don't quite follow your notation
in the last part of the code (after let a: object), but I see:
"other_params": `client=${credentials}&sensor=false&channel=${client}&
libraries=geometry,visualization,places,drawing `,
This would be a problem since the new loader is not yet handling the
other_params parameter. I am actually making a change to support it now,
because it turns out this is the cause of some internal problems as well.
Also, this code makes me wonder:
var script =
<HTMLScriptElement>document.createElement("script");
script.src = "
https://www.google.com/jsapi?callback=MapUtil.googleLoaderCallback";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
MapUtil.loadApiCallback = callback;
Since you add the script tag that includes the
callback=MapUtil.googleLoaderCallback, but I don't see where you have
defined MapUtil.googleLoaderCallback, unless it is the definition of public
static googleLoaderCallback(), which would have to be static methods of
MapUtil.
But since there are multiple callbacks in your code, I am not sure which
callback you are referring to. I see:
if (MapUtil.loaded) { callback(); }
jsapi?callback=MapUtil.googleLoaderCallback
MapUtil.loadApiCallback = callback;
google.load(... {"callback": () => {}})
MapUtil.loadApiCallback();
And are you saying the callback is not called at all, or that it fails for
some reason when it is called?
On Thu, Apr 23, 2020 at 1:31 PM Xiao Lin Liu <[email protected]> wrote:
>
> Also, this is part of the code:
> We only wait for the callback and then get the credentials to log in and
> define our style. but the callback is never invoked in the failed case
>
> public static loadApi(callback: () => void = null): void {
> if (MapUtil.loaded) {
> callback();
> } else {
> var script =
> <HTMLScriptElement>document.createElement("script");
> script.src = "
> https://www.google.com/jsapi?callback=MapUtil.googleLoaderCallback";
> script.type = "text/javascript";
> document.getElementsByTagName("head")[0].appendChild(script);
> MapUtil.loadApiCallback = callback;
> }
> }
> public static googleLoaderCallback() {
> MapUtil.loaded = true;
> let credentials =
> window.sessionStorage.getItem("googleMapsApiCredentials");
> if (credentials === null || credentials === "") {
> KnockoutUtil.ajax({
> url: "/api/configurationapi/GetGoogleMapsAPICredentials",
> type: "GET",
> contentType: "application/json; charset=utf-8",
> dataType: "json",
> async: false,
> success: (data: string) => {
> if (data !== null && data !== "") {
>
> credentials = data;
>
> window.sessionStorage.setItem("googleMapsApiCredentials", credentials);
> }
> },
> error: () => {
> throw new Error("Credentials could not be loaded")
> }
> })
> }
> let a: object;
> (<any>google).load("maps", "3", {
> "other_params":
> `client=${credentials}&sensor=false&channel=${client}&libraries=geometry,visualization,places,drawing
> `,
> "callback": () => {
> MapUtil.impactMap = new
> google.maps.StyledMapType(MapUtil.MAP_IMPACT, { name: "Impact" });
> MapUtil.loadApiCallback();
> MapUtil.createPopupClass();
> }
> });
> }
>
>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-visualization-api/1a2cc920-fdfb-4cc0-a5c6-154704c0e53d%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/1a2cc920-fdfb-4cc0-a5c6-154704c0e53d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]> Cambridge MA
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJOBrtx-wmrSMSmM89%2Bd%3DfSsK6vevZCgRVeTqZ6EJ%3D%2BeYQ%40mail.gmail.com.