<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Google Maps API to display a map in custom visual in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Using-Google-Maps-API-to-display-a-map-in-custom-visual/m-p/3033793#M40827</link>
    <description>&lt;P&gt;As an update, I have attempted to use the solutions given in an old thread which appends options.element directly with Javascript&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;   constructor(options: VisualConstructorOptions) {
        let mapDiv = document.createElement('div');
        mapDiv.id = 'map';
        mapDiv.style.height = "550px";
        options.element.appendChild(mapDiv);        
        let js = document.createElement('script');
        js.innerHTML = "var map;"
                        + "function initMap() {"
                        + "map = new google.maps.Map(document.getElementById('map'), {"
                        + "center: {lat: -34.397, lng: 150.644},"
                        + "zoom: 8"
                        + "});"
                        + "}"
                        + "initMap()";
        options.element.appendChild(js);
        
        js = document.createElement('script');
        js.src="https://maps.googleapis.com/maps/api/js?key=&amp;amp;callback=initMap&amp;amp;v=weekly";
        options.element.appendChild(js);
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;(Thread found here:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Developer/Use-Google-Map-API-in-custom-visual/td-p/190346" target="_blank"&gt;https://community.powerbi.com/t5/Developer/Use-Google-Map-API-in-custom-visual/td-p/190346&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I don't know if this is an issue with PowerBI Visual API being updated since then or an error with my code, but this still gives a blank visual. I have even inspected the code for the visual div element on PowerBI service and can see that the script for the Google Maps API is running - but there still is no output other than a blank window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="burgerboyy_1-1674215201997.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/858999iC597A879E292C3BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="burgerboyy_1-1674215201997.jpeg" alt="burgerboyy_1-1674215201997.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested the same code on a blank HTML page, which displays the map easily enough but it refuses to work on this PowerBI visual - am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2023 11:48:15 GMT</pubDate>
    <dc:creator>burgerboyy</dc:creator>
    <dc:date>2023-01-20T11:48:15Z</dc:date>
    <item>
      <title>Using Google Maps API to display a map in custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Google-Maps-API-to-display-a-map-in-custom-visual/m-p/3031945#M40811</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to making custom visuals in PowerBI and am trying to make a simple visual which simply displays Google Maps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently just trying to get the basic map to initialise on the visual, without specifying any location with data just yet - however, despite being able to successfully run pbiviz start and load this up on PBI Service, all I am able to produce is a blank visual.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing to get the map to display? I am currently using the basic map API example given by Google here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.google.com/maps/documentation/javascript/examples/map-simple#maps_map_simple-typescript" target="_blank"&gt;https://developers.google.com/maps/documentation/javascript/examples/map-simple#maps_map_simple-typescript&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code from my visual.ts (though I have censored my API key) - I'm not seeing any errors either in vscode or in Powershell when doing pbiviz start, but all I get in PowerBI service is a blank visual. How do I just get the basic map showing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;"use strict";

import powerbi from "powerbi-visuals-api";
import { FormattingSettingsService } from "powerbi-visuals-utils-formattingmodel";
import "./../style/visual.less";


import * as d3 from "d3";
type Selection&amp;lt;T extends d3.BaseType&amp;gt; = d3.Selection&amp;lt;T, any,any, any&amp;gt;;
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
import IVisual = powerbi.extensibility.visual.IVisual;
import { VisualFormattingSettingsModel } from "./settings";
import DataView = powerbi.DataView;
import DataViewTable = powerbi.DataViewTable;
import DataViewTableRow = powerbi.DataViewTableRow;
import DataViewMetadataColumn = powerbi.DataViewMetadataColumn;
import DataViewcolumn = powerbi.DataView

export class Visual implements IVisual {
    private target: HTMLElement;
    private textNode: Text;
    private formattingSettings: VisualFormattingSettingsModel;
    private formattingSettingsService: FormattingSettingsService;
    private map: google.maps.Map;
    private div: d3.Selection&amp;lt;SVGElement,any,any,any&amp;gt;;

    constructor(options: VisualConstructorOptions) {
        console.log('Visual constructor', options); //standard
        this.formattingSettingsService = new FormattingSettingsService(); //standard
        this.target = options.element; //standard
        let script = document.createElement('script');
        script.type = 'text/javascript'
        script.src="https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX&amp;amp;callback=initMap";
        document.body.appendChild(script);
        d3.select(options.element)
        .append('div');

    }

    public update(options: VisualUpdateOptions) {
        this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(VisualFormattingSettingsModel, options.dataViews);
        let map: google.maps.Map;
        function initMap(): void {
            const google = window['google'] || window.window['google'];
            map = new google.maps.Map(document.getElementById("map") as HTMLElement, {
            center: { lat: -34.397, lng: 150.644 },
            zoom: 8,
            }); 
            }
    }

    public getFormattingModel(): powerbi.visuals.FormattingModel {
        return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 16:26:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Google-Maps-API-to-display-a-map-in-custom-visual/m-p/3031945#M40811</guid>
      <dc:creator>burgerboyy</dc:creator>
      <dc:date>2023-01-19T16:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Google Maps API to display a map in custom visual</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Using-Google-Maps-API-to-display-a-map-in-custom-visual/m-p/3033793#M40827</link>
      <description>&lt;P&gt;As an update, I have attempted to use the solutions given in an old thread which appends options.element directly with Javascript&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;   constructor(options: VisualConstructorOptions) {
        let mapDiv = document.createElement('div');
        mapDiv.id = 'map';
        mapDiv.style.height = "550px";
        options.element.appendChild(mapDiv);        
        let js = document.createElement('script');
        js.innerHTML = "var map;"
                        + "function initMap() {"
                        + "map = new google.maps.Map(document.getElementById('map'), {"
                        + "center: {lat: -34.397, lng: 150.644},"
                        + "zoom: 8"
                        + "});"
                        + "}"
                        + "initMap()";
        options.element.appendChild(js);
        
        js = document.createElement('script');
        js.src="https://maps.googleapis.com/maps/api/js?key=&amp;amp;callback=initMap&amp;amp;v=weekly";
        options.element.appendChild(js);
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;(Thread found here:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Developer/Use-Google-Map-API-in-custom-visual/td-p/190346" target="_blank"&gt;https://community.powerbi.com/t5/Developer/Use-Google-Map-API-in-custom-visual/td-p/190346&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I don't know if this is an issue with PowerBI Visual API being updated since then or an error with my code, but this still gives a blank visual. I have even inspected the code for the visual div element on PowerBI service and can see that the script for the Google Maps API is running - but there still is no output other than a blank window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="burgerboyy_1-1674215201997.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/858999iC597A879E292C3BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="burgerboyy_1-1674215201997.jpeg" alt="burgerboyy_1-1674215201997.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested the same code on a blank HTML page, which displays the map easily enough but it refuses to work on this PowerBI visual - am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 11:48:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Using-Google-Maps-API-to-display-a-map-in-custom-visual/m-p/3033793#M40827</guid>
      <dc:creator>burgerboyy</dc:creator>
      <dc:date>2023-01-20T11:48:15Z</dc:date>
    </item>
  </channel>
</rss>

