Select to view content in your preferred language

Can I use ArcGIS Online with the Javascript API?

1483
9
Jump to solution
08-15-2014 09:12 AM
ChrisBrannin
Regular Contributor

Hello

I am wondering if I can use ArcGIS Online similar to ArcServer? I am trying to upload tiles to arc online then use them with the API (see below):

<script>

      var map;

  

      require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer("my URL?")", "dojo/domReady!"],

        function(Map, Tiles) {

          map = new Map("map", {basemap: "streets",

          center: [-78.785706, -1.774008], // longitude, latitude

          zoom: 7});

          var tiles = new Tiles("https://tiles.arcgis.com/tiles/.../arcgis/rest/services/ECU_Tiles/MapServer");

          map.addLayer(tiles);

        }

      );

    </script>

I am not sure what the the ("my URL") would be using arcgis online... unless I can't in which case it would make more sense.

Any help and or suggestions are greatly appreciated!

-Chris

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

You will not need to specify a URL in the 'require' portion.  It should just be

require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", ...

See the following help link below:

tiledmapservicelayer-amd | API Reference | ArcGIS API for JavaScript

View solution in original post

0 Kudos
9 Replies
ChrisSergent
Deactivated User

Yes, you can. ArcGIS Online is built on the JavaScript API.

0 Kudos
ChrisBrannin
Regular Contributor

Do you know what I use in the require as my URL or where to find that? I am very new to ArcGIS Online

require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer("my URL?")", "dojo/domReady!"],

Thanks!

-Chris

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Chris,

Yes, if you browse to the tiled service in ArcGIS Online, there will be a rest URL you can use..

0 Kudos
ChrisBrannin
Regular Contributor

is it the same URl I use here?

var tiles = new Tiles("https://tiles.arcgis.com/tiles/.../arcgis/rest/services/ECU_Tiles/MapServer");

0 Kudos
JakeSkinner
Esri Esteemed Contributor

You will not need to specify a URL in the 'require' portion.  It should just be

require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", ...

See the following help link below:

tiledmapservicelayer-amd | API Reference | ArcGIS API for JavaScript

0 Kudos
ChrisBrannin
Regular Contributor

I see... It's working now, thanks for the help!

0 Kudos
ChrisBrannin
Regular Contributor

This might be a silly question but if I don't make the tiles public it's behind a password that aren't my login credentials(arc onlin). Any thoughts on this?

-Chris

0 Kudos
JakeSkinner
Esri Esteemed Contributor

If you have the ability to make a service public or not in ArcGIS Online, you are usually the owner of the service.  Therefore, your ArcGIS.com credentials should be the username/password that can be used.

0 Kudos
ChrisBrannin
Regular Contributor

That's what I would have thought, but it says username/password are incorrect (they are!). Maybe it has something to do with testing the HTML locally. Alright, well thanks again!

Cheers

Chris

0 Kudos