Select to view content in your preferred language

Need Help Google Street Viewer in Flex 1.3

459
2
09-07-2010 03:21 AM
JoshCalhoun
New Contributor
When I load the map and use the widget I get this error(see attached image). I used Robert Scheitlen's code for this

thanks,
Josh

Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<BaseWidget xmlns:esri            ="http://www.esri.com/2008/ags"
   xmlns                 ="com.esri.solutions.flexviewer.*"
   xmlns:mx              ="http://www.adobe.com/2006/mxml"
   xmlns:mxeffects       ="com.adobe.ac.mxeffects.*"
   xmlns:widgets         ="com.esri.solutions.flexviewer.widgets.*"
   x                     ="600"
   y                     ="300">
<mx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.geometry.MapPoint;
   import mx.managers.CursorManager;
   import com.esri.ags.events.MapMouseEvent;
   import mx.controls.Alert;
   import com.esri.ags.SpatialReference;
         import com.esri.ags.events.GeometryServiceEvent;
         import com.esri.solutions.flexviewer.SiteContainer;
        
         [Embed(source="com/esri/solutions/flexviewer/assets/images/cursors/gsv_cursor.png")]
   private var crosshairCursor:Class;
  
   private function google():void{
    this.setMapAction("","Show Google Street View",null);
    map.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    map.panEnabled = false;
    CursorManager.setCursor(crosshairCursor, 2, -8, -12);
   }
  
  
   private function mouseDownHandler (event:MouseEvent):void
   {
    if(SiteContainer.getInstance().controller.status == "Show Google Street View") {
     CursorManager.removeAllCursors();
     CursorManager.setBusyCursor();

     var mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
    
     var coordGraphic:Graphic = new Graphic(mapPoint, smsPoint);
     var outSR:SpatialReference = new SpatialReference(2274);
     geometryService.project([coordGraphic], outSR);
    } else {
     map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    }
   }
  
   private function widgetClosedHandler(event:Event):void
   {
    map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    map.panEnabled = true;
    CursorManager.removeAllCursors();
    setMapNavigation(null, null);
   }
  
   private function projectCompleteHandler(event:GeometryServiceEvent):void
   {
    var g:Graphic = event.graphics[0];
    var mapPoint:MapPoint = g.geometry as MapPoint;
    var lng:String = mapPoint.x.toFixed(13);
    var lat:String = mapPoint.y.toFixed(13);
    // launch street view
    var url:String  = "http://74.116.50.125/FlexView/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 );
   
    CursorManager.removeAllCursors();
    CursorManager.setCursor(crosshairCursor, 2, -8, -12);
   }
  
   private function onFault(info:Object, token:Object = null):void
         {
             Alert.show(info.toString());
         }
  ]]>
</mx:Script>
<mx:String id="pointLabel">Select a Google Streetview Point</mx:String>
<mx:String id="povIconUrl">com/esri/solutions/flexviewer/assets/images/icons/i_pov.png</mx:String>
<WidgetTemplate
  id="widgetTempalte"
  widgetClosed="widgetClosedHandler(event)"
  widgetOpened="google()"
  widgetMinimized="widgetClosedHandler(event)"
  creationComplete="google()">
  <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"/>
            </mx:HBox>
            <mx:Button click="google()" label="Reactivate..."/>
        </mx:VBox>
</WidgetTemplate>
<esri:GeometryService
            id="geometryService"
            concurrency="last"
            fault="onFault(event)"
            projectComplete="projectCompleteHandler(event)"
            url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
        />
    <esri:SimpleMarkerSymbol id="smsPoint" style="square" color="0xFFFF00" size="11" alpha="0.9">
     <esri:SimpleLineSymbol color="0x000000"/>
    </esri:SimpleMarkerSymbol>
</BaseWidget>
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Josh,

   A 404 Error just means that it can not find the page. So it is looking for http://74.116.50.125/FlexView/StreetView.html and it can not find it. So the obvious question is do you have a virtual directory named FlexView and the file StreetView.html in it on the web server that has the IP Address of 74.116.50.125? That question is almost 98% rhetorical because that is what the error is say that there is not one. If you are on your development machine (different IP) and are trying to test this widget than you either need to change the url or you need to actually add a 'FleView' virtual directory to 74.116.50.125 and then copy StreetView.html into it.
0 Kudos
JoshCalhoun
New Contributor
Thanks Robert,

I created a virtual directory based on the url I specified in the StreetViewWidget.mxml and it worked.

One more thing I would like to add for those of you out there reading this. Make sure that you keep the default spatial ref number(WKID located on line 40). I changed this to TN state plane and it did not work even though my map is in TN state plane. I changed it back and it works great now.

Robert you posses great GIS muscle.

thanks
Josh Calhoun
0 Kudos