Skip to main content

Hey Everyone,

I'm trying to do some javascript work with FME Server. I can't seem to connect to my server that runs FME Server. I have the FMEServer.init method set up window.onload but I get the attached error. The onload code is below too, the FMEServer.init portion is near the bottom.

 

0684Q00000ArAeFQAV.jpg

 

window.onload = function()
{
debugger;
require(a
"esri/map", "esri/toolbars/draw",
"esri/graphic", "esri/geometry/webMercatorUtils",
"esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol",
"dojo/_base/Color", "dojo/dom", "dojo/on", "dojo/domReady!"
], function(
Map, Draw,
Graphic, webMercatorUtils,
SimpleLineSymbol, SimpleFillSymbol,
Color, dom, on
)
{
map = new Map("mapDiv",
{
basemap: "hybrid", //Select the basemap
center: "-155.114166, 70.27], //Enter the coordinates to center the map
zoom: 7, //Set the default zoom
minZoom: 4,//Set the minimum zoom level
smartNavigation: false
});

map.on("load", function()
{
toolbar = new Draw(map);

dojo.connect(toolbar, "onDrawEnd", addToMap);

on(dom.byId("draw"), "click", drawPolyline);
on(dom.byId("reset"), "click", drawReset);
});

function addToMap(geometry)
{
var symbol = new SimpleFillSymbol(
SimpleFillSymbol.STYLE_NULL,
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color(>255, 0, 0]), 2
),
new Color( 255, 255, 0, 0.25])
);
geometry = webMercatorUtils.webMercatorToGeographic(geometry);
var graphic = new Graphic(geometry, symbol);
map.graphics.clear();
map.graphics.add(graphic);
toolbar.deactivate(Draw.POLYLINE);
storedGeometry = geometry.pathsp0];
}

function drawPolyline()
{
drawReset();
toolbar.activate(esri.toolbars.Draw.POLYLINE);


}

function drawReset()
{
toolbar.deactivate(esri.toolbars.Draw.POLYLINE);
map.graphics.clear();
}
});
debugger;
FMEServer.init(
{

server: "http://hocwapp0053", //Update with your Server hostname - on FME training machines this is http://fmetraining
token: "7a2fce751ef10468fe6952670ccebcaa449edc39" //Update to your fmetoken

});
};

Hi @fme_noob,

In your code somewhere are you initializing the FME JavaScript API?

It should look something like this

<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>

Hi @fme_noob,

In your code somewhere are you initializing the FME JavaScript API?

It should look something like this

<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>

Hey @siennaatsafe thanks for the repsonse. I do have that bit in my html head

 

<head>
<title>Example</title>
<!-- Styles for example -->
<link rel="stylesheet" href="http://playground.fmeserver.com/css/FMEServerExamples.css" type="text/css" />
<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>
<!-- The following are Required for ArcGIS Maps -->
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css" />
<script type="text/javascript" src="http://js.arcgis.com/3.8/"></script>
<!-- <script type="text/javascript" src="jquery-3.3.1.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="Javascript/Alaskajs.js"></script>
</head>

Hey @siennaatsafe thanks for the repsonse. I do have that bit in my html head

 

<head>
<title>Example</title>
<!-- Styles for example -->
<link rel="stylesheet" href="http://playground.fmeserver.com/css/FMEServerExamples.css" type="text/css" />
<!-- Include FMEServer.js -->
<script type="text/javascript" src="https://api.fmeserver.com/js/v3/FMEServer.js"></script>
<!-- The following are Required for ArcGIS Maps -->
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css" />
<script type="text/javascript" src="http://js.arcgis.com/3.8/"></script>
<!-- <script type="text/javascript" src="jquery-3.3.1.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="Javascript/Alaskajs.js"></script>
</head>

Hi @fme_noob,

Could you put all your code into something like JS fiddle so I can take a look? https://jsfiddle.net/


Hi @fme_noob,

Could you put all your code into something like JS fiddle so I can take a look? https://jsfiddle.net/

@siennaatsafe I've copy/pasted it in jsfiddle. IT partially won't work because my html/js file are in my own folder structure atm: https://jsfiddle.net/cmclellan/8fynkcje/


@siennaatsafe I've copy/pasted it in jsfiddle. IT partially won't work because my html/js file are in my own folder structure atm: https://jsfiddle.net/cmclellan/8fynkcje/

Hi @fme_noob,

When I have your code like this I can get a response back from the Server. https://jsfiddle.net/90jrdgzt/3/


Hi @fme_noob,

When I have your code like this I can get a response back from the Server. https://jsfiddle.net/90jrdgzt/3/

My issue seems to be when I try to replace the server with my own company server thats hosting my FMEServer

You have https://bluesky-safe-software.fmecloud.com/ on line 72 of the javascript but I have to change it to my own. Are there any guidelines to accomplishing this?

 


My issue seems to be when I try to replace the server with my own company server thats hosting my FMEServer

You have https://bluesky-safe-software.fmecloud.com/ on line 72 of the javascript but I have to change it to my own. Are there any guidelines to accomplishing this?

 

I think JS fiddle doesn't like servers with http. However, this code on a normal server should work with http or https. How are you hosting your code? Could you try something like the python example here? https://s3.amazonaws.com/gitbook/Server-REST-API-UC20/FMESERVER_RESTAPI8Session2/8.2.HostingWebApplications.html


I think JS fiddle doesn't like servers with http. However, this code on a normal server should work with http or https. How are you hosting your code? Could you try something like the python example here? https://s3.amazonaws.com/gitbook/Server-REST-API-UC20/FMESERVER_RESTAPI8Session2/8.2.HostingWebApplications.html

Hey @siennaatsafe

Since this is an internal tool at my company, I wasn't sure what if any hosting I needed to perform. Does Safe have any on-prem servers and has anyone tried the FMEServer.init function in that situation?


Hey @siennaatsafe

Since this is an internal tool at my company, I wasn't sure what if any hosting I needed to perform. Does Safe have any on-prem servers and has anyone tried the FMEServer.init function in that situation?

Hi @fme_noob,

I've tested these with the Python server which creates a local web server for testing and it worked for me. https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server


Hi @fme_noob,

I've tested these with the Python server which creates a local web server for testing and it worked for me. https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

Hey @siennaatsafe

So I logged onto my server and used the python method to set up a http://localhost:8000. I ran the html through the local host and for some reason my server is still undefined on the init function.


Reply