<?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 Custom Widget can't access my mapview in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/custom-widget-can-t-access-my-mapview/m-p/1543826#M1481</link>
    <description>&lt;P&gt;I am updating my JS API from 4.13 to 4.30. I have a custom widget that uses the mapview and an eventhandler to acquire the X, Y coordinates of the users input ( a click event). Using Typescript&amp;nbsp; &amp;nbsp;in Visual Studios i am not getting an error with my code but when i publish and run it the it can't find a property for "this.view.on" any advice or ideas would be apperciated.&lt;/P&gt;&lt;P&gt;Typescript code from widget:&lt;/P&gt;&lt;P&gt;import Widget = require("esri/widgets/Widget");&lt;BR /&gt;import Point = require("esri/geometry/Point");&lt;BR /&gt;import MapView = require("esri/views/MapView");&lt;BR /&gt;import IdentifyResult = require("esri/rest/support/IdentifyResult");&lt;BR /&gt;import Request = require("esri/request");&lt;BR /&gt;import SimpleMarkerSymbol = require("esri/symbols/SimpleMarkerSymbol");&lt;BR /&gt;//import { subclass, declared, property } from "esri/core/accessorSupport/decorators";&lt;BR /&gt;import { tsx } from "esri/widgets/support/widget";&lt;BR /&gt;//import watchUtils = require("esri/core/watchUtils");&lt;BR /&gt;import Popup = require("esri/widgets/Popup");&lt;BR /&gt;import { property, subclass } from "esri/core/accessorSupport/decorators";&lt;BR /&gt;import { Event } from "jquery";&lt;BR /&gt;import RouteLayer = require("esri/layers/RouteLayer");&lt;BR /&gt;import FeatureLayer = require("esri/layers/FeatureLayer");&lt;BR /&gt;import reactiveUtils = require("esri/core/reactiveUtils");&lt;BR /&gt;import View = require("esri/views/View");&lt;BR /&gt;type Coordinates = Point | number[] | any;&lt;BR /&gt;var eventHandler: any;&lt;BR /&gt;var ReactiveUtils: reactiveUtils;&lt;BR /&gt;var popup: Popup;&lt;BR /&gt;interface Center {&lt;BR /&gt;x: number;&lt;BR /&gt;y: number;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;interface State extends Center {&lt;BR /&gt;interacting: boolean;&lt;BR /&gt;scale: number;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const CSS = {&lt;BR /&gt;base: "recenter-tool"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@subclass("esri.widgets.Recenter")&lt;BR /&gt;class Steetview extends (Widget) {&lt;BR /&gt;@property()&lt;BR /&gt;RouteLayer: FeatureLayer;&lt;BR /&gt;@property()&lt;BR /&gt;view: MapView;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;private _btnClickForGSV() {&lt;BR /&gt;&lt;BR /&gt;(document.getElementById("OffStreetView") as HTMLButtonElement).style.visibility = 'visible';&lt;BR /&gt;(document.getElementById("goToStreetView") as HTMLButtonElement).style.visibility = 'hidden';&lt;BR /&gt;//this.RouteLayer.popupEnabled = false;&lt;BR /&gt;//popup.autoCloseEnabled = false;&lt;BR /&gt;//(this.view.popup as Popup).autoCloseEnabled = false;&lt;BR /&gt;&lt;BR /&gt;(document.getElementById("viewDiv") as HTMLDivElement).style.cursor = "pointer";&lt;BR /&gt;debugger;&lt;/P&gt;&lt;P&gt;eventHandler = this.view.on("click", (event: __esri.ViewClickEvent) =&amp;gt; {&lt;BR /&gt;//var ru = reactiveUtils.on(() =&amp;gt; this.view, "click", (event) =&amp;gt; {&lt;BR /&gt;debugger;&lt;BR /&gt;var viewX = event.mapPoint.latitude;&lt;BR /&gt;var viewY = event.mapPoint.longitude;&lt;BR /&gt;//var linkSV = '&amp;lt;a href="&lt;A href="https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=" target="_blank" rel="noopener"&gt;https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=&lt;/A&gt;' + viewX.toString() + "," + viewY.toString() + '"target="_blank"&amp;gt;' + viewX.toString() + "," + viewY.toString() + "&amp;lt;/a&amp;gt;";&lt;BR /&gt;//document.getElementById('lbLink').innerHTML = linkSV;&lt;BR /&gt;var GSVURL = '&lt;A href="https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=" target="_blank" rel="noopener"&gt;https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=&lt;/A&gt;' + viewX.toString() + "," + viewY.toString();&lt;BR /&gt;&lt;BR /&gt;(window as any).open(GSVURL).focus();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;private _btnturnoffGSV() {&lt;BR /&gt;(document.getElementById("goToStreetView") as HTMLButtonElement).style.visibility = 'visible';&lt;BR /&gt;(document.getElementById("OffStreetView") as HTMLButtonElement).style.visibility = 'hidden';&lt;BR /&gt;//this.RouteLayer.popupEnabled = true;&lt;BR /&gt;//this.view.popupEnabled = true;&lt;BR /&gt;//popup.autoCloseEnabled = true;&lt;BR /&gt;//(this.view.popup as Popup).autoCloseEnabled = true;&lt;BR /&gt;(document.getElementById("viewDiv") as HTMLDivElement).style.cursor = "auto";&lt;BR /&gt;eventHandler.remove();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;constructor() {&lt;BR /&gt;super();&lt;BR /&gt;this._onViewChange = this._onViewChange.bind(this)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//postInitialize() {&lt;BR /&gt;// watchUtils.init(this, "view.center, view.interacting, view.scale", () =&amp;gt; this._onViewChange());&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@property()&lt;BR /&gt;//@renderable()&lt;BR /&gt;state: State;&lt;/P&gt;&lt;P&gt;@property()&lt;BR /&gt;//@renderable()&lt;BR /&gt;initialCenter: Coordinates;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;render() {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;return (&lt;/P&gt;&lt;P&gt;&amp;lt;div&lt;BR /&gt;bind={this}&lt;BR /&gt;class={CSS.base}&lt;BR /&gt;style=" border-radius: 15px;"&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;lt;h5&amp;gt;&amp;lt;b&amp;gt;Google Street View Link&amp;lt;/b&amp;gt;&amp;lt;/h5&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;button type="button" class="btn btn-success" id="goToStreetView" bind={this} style="visibility:visible" align="left" onclick={this._btnClickForGSV}&amp;gt;Turn ON Street Viewer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;amp;nbsp; &amp;lt;button id="OffStreetView" class="btn btn-danger" bind={this} style="visibility:hidden" align="left" type="button" value="SV off" onclick={this._btnturnoffGSV}&amp;gt;Turn OFF Street Viewer&amp;lt;/button &amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private _onViewChange() {&lt;BR /&gt;let { interacting, center, scale } = this.view;&lt;BR /&gt;this.state = {&lt;BR /&gt;x: center.x,&lt;BR /&gt;y: center.y,&lt;/P&gt;&lt;P&gt;interacting,&lt;BR /&gt;scale&lt;BR /&gt;};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;export = Steetview;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Sep 2024 15:33:07 GMT</pubDate>
    <dc:creator>TaylorProulx</dc:creator>
    <dc:date>2024-09-30T15:33:07Z</dc:date>
    <item>
      <title>Custom Widget can't access my mapview</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/custom-widget-can-t-access-my-mapview/m-p/1543826#M1481</link>
      <description>&lt;P&gt;I am updating my JS API from 4.13 to 4.30. I have a custom widget that uses the mapview and an eventhandler to acquire the X, Y coordinates of the users input ( a click event). Using Typescript&amp;nbsp; &amp;nbsp;in Visual Studios i am not getting an error with my code but when i publish and run it the it can't find a property for "this.view.on" any advice or ideas would be apperciated.&lt;/P&gt;&lt;P&gt;Typescript code from widget:&lt;/P&gt;&lt;P&gt;import Widget = require("esri/widgets/Widget");&lt;BR /&gt;import Point = require("esri/geometry/Point");&lt;BR /&gt;import MapView = require("esri/views/MapView");&lt;BR /&gt;import IdentifyResult = require("esri/rest/support/IdentifyResult");&lt;BR /&gt;import Request = require("esri/request");&lt;BR /&gt;import SimpleMarkerSymbol = require("esri/symbols/SimpleMarkerSymbol");&lt;BR /&gt;//import { subclass, declared, property } from "esri/core/accessorSupport/decorators";&lt;BR /&gt;import { tsx } from "esri/widgets/support/widget";&lt;BR /&gt;//import watchUtils = require("esri/core/watchUtils");&lt;BR /&gt;import Popup = require("esri/widgets/Popup");&lt;BR /&gt;import { property, subclass } from "esri/core/accessorSupport/decorators";&lt;BR /&gt;import { Event } from "jquery";&lt;BR /&gt;import RouteLayer = require("esri/layers/RouteLayer");&lt;BR /&gt;import FeatureLayer = require("esri/layers/FeatureLayer");&lt;BR /&gt;import reactiveUtils = require("esri/core/reactiveUtils");&lt;BR /&gt;import View = require("esri/views/View");&lt;BR /&gt;type Coordinates = Point | number[] | any;&lt;BR /&gt;var eventHandler: any;&lt;BR /&gt;var ReactiveUtils: reactiveUtils;&lt;BR /&gt;var popup: Popup;&lt;BR /&gt;interface Center {&lt;BR /&gt;x: number;&lt;BR /&gt;y: number;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;interface State extends Center {&lt;BR /&gt;interacting: boolean;&lt;BR /&gt;scale: number;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const CSS = {&lt;BR /&gt;base: "recenter-tool"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@subclass("esri.widgets.Recenter")&lt;BR /&gt;class Steetview extends (Widget) {&lt;BR /&gt;@property()&lt;BR /&gt;RouteLayer: FeatureLayer;&lt;BR /&gt;@property()&lt;BR /&gt;view: MapView;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;private _btnClickForGSV() {&lt;BR /&gt;&lt;BR /&gt;(document.getElementById("OffStreetView") as HTMLButtonElement).style.visibility = 'visible';&lt;BR /&gt;(document.getElementById("goToStreetView") as HTMLButtonElement).style.visibility = 'hidden';&lt;BR /&gt;//this.RouteLayer.popupEnabled = false;&lt;BR /&gt;//popup.autoCloseEnabled = false;&lt;BR /&gt;//(this.view.popup as Popup).autoCloseEnabled = false;&lt;BR /&gt;&lt;BR /&gt;(document.getElementById("viewDiv") as HTMLDivElement).style.cursor = "pointer";&lt;BR /&gt;debugger;&lt;/P&gt;&lt;P&gt;eventHandler = this.view.on("click", (event: __esri.ViewClickEvent) =&amp;gt; {&lt;BR /&gt;//var ru = reactiveUtils.on(() =&amp;gt; this.view, "click", (event) =&amp;gt; {&lt;BR /&gt;debugger;&lt;BR /&gt;var viewX = event.mapPoint.latitude;&lt;BR /&gt;var viewY = event.mapPoint.longitude;&lt;BR /&gt;//var linkSV = '&amp;lt;a href="&lt;A href="https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=" target="_blank" rel="noopener"&gt;https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=&lt;/A&gt;' + viewX.toString() + "," + viewY.toString() + '"target="_blank"&amp;gt;' + viewX.toString() + "," + viewY.toString() + "&amp;lt;/a&amp;gt;";&lt;BR /&gt;//document.getElementById('lbLink').innerHTML = linkSV;&lt;BR /&gt;var GSVURL = '&lt;A href="https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=" target="_blank" rel="noopener"&gt;https://www.google.com/maps/@?api=1&amp;amp;map_action=pano&amp;amp;viewpoint=&lt;/A&gt;' + viewX.toString() + "," + viewY.toString();&lt;BR /&gt;&lt;BR /&gt;(window as any).open(GSVURL).focus();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;private _btnturnoffGSV() {&lt;BR /&gt;(document.getElementById("goToStreetView") as HTMLButtonElement).style.visibility = 'visible';&lt;BR /&gt;(document.getElementById("OffStreetView") as HTMLButtonElement).style.visibility = 'hidden';&lt;BR /&gt;//this.RouteLayer.popupEnabled = true;&lt;BR /&gt;//this.view.popupEnabled = true;&lt;BR /&gt;//popup.autoCloseEnabled = true;&lt;BR /&gt;//(this.view.popup as Popup).autoCloseEnabled = true;&lt;BR /&gt;(document.getElementById("viewDiv") as HTMLDivElement).style.cursor = "auto";&lt;BR /&gt;eventHandler.remove();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;constructor() {&lt;BR /&gt;super();&lt;BR /&gt;this._onViewChange = this._onViewChange.bind(this)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//postInitialize() {&lt;BR /&gt;// watchUtils.init(this, "view.center, view.interacting, view.scale", () =&amp;gt; this._onViewChange());&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@property()&lt;BR /&gt;//@renderable()&lt;BR /&gt;state: State;&lt;/P&gt;&lt;P&gt;@property()&lt;BR /&gt;//@renderable()&lt;BR /&gt;initialCenter: Coordinates;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;render() {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;return (&lt;/P&gt;&lt;P&gt;&amp;lt;div&lt;BR /&gt;bind={this}&lt;BR /&gt;class={CSS.base}&lt;BR /&gt;style=" border-radius: 15px;"&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;lt;h5&amp;gt;&amp;lt;b&amp;gt;Google Street View Link&amp;lt;/b&amp;gt;&amp;lt;/h5&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;button type="button" class="btn btn-success" id="goToStreetView" bind={this} style="visibility:visible" align="left" onclick={this._btnClickForGSV}&amp;gt;Turn ON Street Viewer&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;amp;nbsp; &amp;lt;button id="OffStreetView" class="btn btn-danger" bind={this} style="visibility:hidden" align="left" type="button" value="SV off" onclick={this._btnturnoffGSV}&amp;gt;Turn OFF Street Viewer&amp;lt;/button &amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private _onViewChange() {&lt;BR /&gt;let { interacting, center, scale } = this.view;&lt;BR /&gt;this.state = {&lt;BR /&gt;x: center.x,&lt;BR /&gt;y: center.y,&lt;/P&gt;&lt;P&gt;interacting,&lt;BR /&gt;scale&lt;BR /&gt;};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;export = Steetview;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 15:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/custom-widget-can-t-access-my-mapview/m-p/1543826#M1481</guid>
      <dc:creator>TaylorProulx</dc:creator>
      <dc:date>2024-09-30T15:33:07Z</dc:date>
    </item>
  </channel>
</rss>

