Select to view content in your preferred language

Google Street View widget error in SFV 2.0

2184
14
08-17-2010 11:26 AM
SreeS
by
Emerging Contributor
I was using Google Street View in SFV 1.3 I made some changes to it to use it in SFV 2.0.

But im getting the error shown in the jpg after I activate the GSV and click on map.

When I traced, I found that the problem is with geometry projection:

geometryService.project([ mapPoint as Geometry ], outSR) ;
0 Kudos
14 Replies
by Anonymous User
Not applicable
Original User: rscheitlin

Sree,

   Just change the mentioned line to this

geometryService.project([mapPoint], outSR);
0 Kudos
SreeS
by
Emerging Contributor
That didnt work Robert.  Im still getting the same error.

I dont know what Im missing.
0 Kudos
by Anonymous User
Not applicable
Original User: bjorn

"Hidden" far down on the "Migration from 1.3 to 2.0" page, http://help.arcgis.com/en/webapi/flex/help/index.html#migrating.htm.

* Inputs for GeometryService  are now geometries instead of graphics.
    //1.3:
    geometryService.project(graphics, new SpatialReference(32618));
    //2.0:
    geometryService.project([graphic.geometry], new SpatialReference(32618));

Which I think is the same as Robert's suggestion...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sree,

   I am not sure what is going wrong either here is all I have in my mouse down event handler

var mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
     var outSR:SpatialReference = new SpatialReference(4326);
     geometryService.project([mapPoint], outSR);
0 Kudos
by Anonymous User
Not applicable
Original User: brendanbrendan

Hi,
I am also getting a load error with the SV widget in V2.0.
The attached image sows the Load Error. Once this error is closed the widget works correctly.
Any ideas why this "Application Error" occurs?
I am guessing this is something small - it is the first widget I have integrated into the Flex Viewer 2.0 so not sure if it is a problem with an additional file.
I have updated the GeometryService from the above file (StreetView.mxml.txt) to point to my local geometry service and this is working fine.
I am using Flex SDK 4.1
Thanks,
Brendan
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
guys,

   Does your projection complete look something like this/

var geom:Geometry = (event.result as Array)[0];
    var mapPoint:MapPoint = geom as MapPoint;
    var lng:String = mapPoint.x.toFixed(12);
    var lat:String = mapPoint.y.toFixed(12);
    // launch street view
                               etc etc
0 Kudos
by Anonymous User
Not applicable
Original User: brendanbrendan

Hi,
My code as follows:

   private function projectCompleteHandler(event:GeometryServiceEvent):void
   {
    
    var mapPoint:MapPoint = (event.result as Array)[0]as MapPoint;
    var lng:String = mapPoint.x.toFixed(3);
    var lat:String = mapPoint.y.toFixed(3);
    // launch street view
    var url:String  = "http://gis.kilkennycoco.ie/flex/streetview/index.html?lat=" + lat + "&lng=" + lng;
    var window:String = "_blank";
    var features:String = "toolbar=no,location=no,resizable=no,directories=no,status=no,scrollbars=no,copyhistory=no,width=600,height=400";
    
    var WINDOW_OPEN_FUNCTION : String = "window.open";
    ExternalInterface.call( WINDOW_OPEN_FUNCTION, url, window, features );
    
    CursorManager.removeAllCursors();
   }


Thanks for getting back to me,
Brendan
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Brendan,


  Now you will not be able to use my whole code word for word as I do things with the Flexviewer2.0 that you will not have but here is my code and it works fine. Maybe you can see where you are going wrong.

<?xml version="1.0" encoding="utf-8"?>
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx"
       xmlns:viewer="com.esri.viewer.*"
       xmlns:esri="http://www.esri.com/2008/ags"
       xmlns:mxeffects="com.adobe.ac.mxeffects.*"
       layout="absolute" 
       creationComplete="addStatList()">
 <fx:Declarations>
  <esri:GeometryService
   id="geometryService"
   concurrency="last"
   fault="onFault(event)"
   projectComplete="projectCompleteHandler(event)"
   url="http://gis.calhouncounty.org/arcgis2/rest/services/Geometry/GeometryServer"/>
  <esri:SimpleMarkerSymbol id="smsPoint" style="square" color="0xFFFF00" size="11" alpha="0.9">
   <esri:SimpleLineSymbol color="0x000000"/>
  </esri:SimpleMarkerSymbol>
 </fx:Declarations>
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.events.GeometryServiceEvent;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.viewer.AppEvent;
   import com.esri.viewer.ViewerContainer;
   
   import mx.controls.Alert;
   import mx.managers.CursorManager;
   
   [Embed(source="assets/images/gsv_cursor.png")]
   private var crosshairCursor:Class;
   
   private var theStatus:String = "";
   
   public function google():void{
    setMapAction("","Show Google Street View",null);
    map.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    map.panEnabled = false;
    map.cursorManager.setCursor(crosshairCursor, 2, -8, -12);
   }
   
   private function mouseDownHandler (event:MouseEvent):void
   {
    if(theStatus == "Show Google Street View") {
     map.cursorManager.setBusyCursor();
     
     var mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
     var outSR:SpatialReference = new SpatialReference(4326);
     geometryService.project([mapPoint], outSR);
    } else {
     map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    }
   }
   
   private function widgetClosedHandler(event:Event):void
   {
    map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    map.panEnabled = true;
    map.cursorManager.removeCursor(map.cursorManager.currentCursorID);
    setMapNavigation(null, null);
   }
   
   private function widgetOpenedHandler(event:Event):void
   {
    google();
   }
   
   private function addStatList():void
   {
    ViewerContainer.addEventListener(AppEvent.SET_STATUS, statusSet);
    theStatus = "Show Google Street View";
   }
   
   private function statusSet(event:AppEvent):void
   {
    if (event.data)
     theStatus = event.data as String;
   }
   
   private function projectCompleteHandler(event:GeometryServiceEvent):void
   {
    var geom:Geometry = (event.result as Array)[0];
    var mapPoint:MapPoint = geom as MapPoint;
    var lng:String = mapPoint.x.toFixed(12);
    var lat:String = mapPoint.y.toFixed(12);
    // launch street view
    var url:String  = "http://gis.calhouncounty.org/FlexViewer2.0/StreetView.html?lat=" + lat + "&lng=" + lng;
    var window:String = "StreetView";
    var features:String = "toolbar=no,location=no,resizable=no,directories=no,status=no,scrollbars=no,copyhistory=no,width=610,height=700";
    
    var WINDOW_OPEN_FUNCTION : String = "window.open";
    ExternalInterface.call( WINDOW_OPEN_FUNCTION, url, window, features );
   }
   
   private function onFault(info:Object, token:Object = null):void
   {
    Alert.show(info.toString(),"Streetview Error");
   }

   protected function button1_clickHandler(event:MouseEvent):void
   {
    ViewerContainer.showError("This is a test error");
   }

  ]]>
 </fx:Script>
 <viewer:WidgetTemplate id="wTemplate"
  closed="widgetClosedHandler(event)"
  open="widgetOpenedHandler(event)"
  creationComplete="google()"
  skinClass="com.esri.viewer.skins.WidgetTemplateSkin"
  height="280"
  width="370">
  <mx:VBox width="100%" height="100%" 
     verticalGap="4" 
     horizontalAlign="center" 
     verticalAlign="middle" >
   <mx:HBox width="100%" 
      horizontalGap="15" 
      horizontalAlign="center"
      verticalAlign="middle">
    <mx:Text id="selectPointLabelText" 
       text="Click location on the map to open Google® streetview panorama" 
       styleName="WidgetText" width="90%" textAlign="center"/>
   </mx:HBox>
   <mx:Button click="google()" label="Reactivate..."/>
  </mx:VBox>
 </viewer:WidgetTemplate>
</viewer:BaseWidget>
0 Kudos
by Anonymous User
Not applicable
Original User: philipp37

Finally got the Streetview widget upgraded and working from SFV 1.3 to 2.0 and then I came across this post 🙂

One request to make the widget work better for my purposes - how could you remove the streetview cursor from the mouse once the widget is closed?  When the widget is closed there should be no reference at all to anything in the streetview.mxml.

Thanks for the help!
0 Kudos