ArcGIS Server and GPS JS API

966
5
09-17-2012 11:52 AM
GyeyoungChoi
New Contributor II
Hi all,

I was playing with arcserver and web mapping function.

I found this and wanted to try however have not much idea of JS
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/exp_geolocate....

so, I thought changing url for map location
from
http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer
to
http://myserver/arcgis/rest/services/folder/webmap/MapServer"

but did not work.

can anyone help me with this?

Thanks,

Tim
0 Kudos
5 Replies
StephenLead
Regular Contributor III
I found this and wanted to try however have not much idea of JS
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/exp_geolocate....

so, I thought changing url for map location
from http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer
to http://myserver/arcgis/rest/services/folder/webmap/MapServer" but did not work.


Hi Tim,

Welcome to the JS forum. Can you be clearer about what you're trying to do? Are you trying to replace the ocean basemap with another basemap? Exactly which part of your code is failing?

If you open up http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer in a web browser you'll see the REST endpoint, containing information about that service. What happens when you try your own server - do you see the same type of information?

The Ocean_Basemap service is cached (Note that it says "Single Fused Map Cache: true"), which is necessary to display a tiled layer. See http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/arcgistiledmapservicelayer.htm for more info.

Steve
0 Kudos
GyeyoungChoi
New Contributor II
Hi Tim,

Welcome to the JS forum. Can you be clearer about what you're trying to do? Are you trying to replace the ocean basemap with another basemap? Exactly which part of your code is failing?

If you open up http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer in a web browser you'll see the REST endpoint, containing information about that service. What happens when you try your own server - do you see the same type of information?

The Ocean_Basemap service is cached (Note that it says "Single Fused Map Cache: true"), which is necessary to display a tiled layer. See http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/arcgistiledmapservicelayer.htm for more info.

Steve




function init() {
                        //onorientationchange doesn't always fire in a timely manner in Android so check for both orientationchange and resize
                        var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

                        window.addEventListener(orientationEvent, function() {
                              orientationChanged();
                        }, false);

                        map = new esri.Map("map");
                        dojo.connect(map, "onLoad", initFunc);
                        var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
                        map.addLayer(tiledMapServiceLayer);
                  }



function init() {

    map = new esri.Map("map",{logo:false});
          var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://locahost/arcgis/rest/services/landscape/grass_mapping/MapServer");
          map.addLayer(layer);
    var resizeTimer;
    dojo.connect(map, 'onLoad', function(theMap) {
      dojo.connect(dijit.byId('map'), 'resize', function() {
        clearTimeout(resizeTimer);
        resizeTimer = setTimeout(function() {
          map.resize();
          map.reposition();
         }, 500);
       });
     });
}

Hi Steve,
Thank you for answer
so, upper code is from the api sample and the bottom one is that I used for webmapping

So basically I replaced init() and add dojo.require as well

but I'm not sure what should I do other than replacing

Thank you

Tim
0 Kudos
StephenLead
Regular Contributor III
Hi Tim,

I'm still not sure what you're actually trying to do.

It looks like you're using a Dynamic layer, so perhaps you could start by modifying the Dynamic Map sample.

Your code uses:

var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://locahost/arcgis/rest/services/landscape/grass_mapping/MapServer");
map.addLayer(layer);


Have you verified that http://locahost/arcgis/rest/services/landscape/grass_mapping/MapServer is valid - does it appear in a similar manner to the sample service http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapSer... ?
0 Kudos
GyeyoungChoi
New Contributor II
Hi Tim,

I'm still not sure what you're actually trying to do.

It looks like you're using a Dynamic layer, so perhaps you could start by modifying the Dynamic Map sample.

Your code uses:

var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://locahost/arcgis/rest/services/landscape/grass_mapping/MapServer");
map.addLayer(layer);


Have you verified that http://locahost/arcgis/rest/services/landscape/grass_mapping/MapServer is valid - does it appear in a similar manner to the sample service http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapSer... ?


Hello Steve,

Yes, my map is working fine, I just wanted add GPS "option"
the map works on my desktop and my phone as well.

The reason why I post two init() function is because
since my map is working COPY my init() PASTE into GPS API Source which located
"http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/mobile_geoloca..."

however didn't work that way (I didn't expect that easy anyways).

so my question is how to use "mobile_geolocaterenderer" source code with my map

Thank you,

Tim
0 Kudos
StephenLead
Regular Contributor III
so my question is how to use "mobile_geolocaterenderer" source code with my map


Hi Tim,

All I can suggest is that you work through the example you referenced at http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/exp_geolocate....

At a high level, here is what it's doing:

dojo.addOnLoad(init);


This runs the init function when the page first loads. The init function sets up the map, and adds a background tiled layer.

dojo.connect(map, "onLoad", initFunc);


This runs the initFunc function once the basemap has loaded. See the comments at the top of the sample script's page to see what this function is doing:

In the snippet below, we check to see if browser supports geolocation, if it does we use the getCurrentPosition and watchPosition functions. The getCurrentPosition function retrieves the users current location and watchPosition tracks the users position as it changes. Both functions have the same structure, a success callback, error callback and a PositionOptions object


The function uses:

navigator.geolocation.getCurrentPosition(zoomToLocation, locationError);


which means that the zoomToLocation function is called - this adds a graphic to the map at the user's current location.

Hope this helps,
Steve
0 Kudos