Problem displaying dynamic map services with ArcGIS Google API

417
5
05-29-2012 05:15 AM
CurtWalker
New Contributor
The knowledge base article shows how to overlay a service from ArcGIS Server over the google maps base layer.  The code in the article works perfectly until I replace the dynamic URL with my own map service.  I cannot get any of our dynamic map services to overlay like the ESRI one does.  Here's my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
  <title>ArcGIS JavaScript Extension for the Google Maps API Example</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyDDlcIQ61bcnNSaLKNoBaD6u09Yq1WuUb8" type="text/javascript"></script>
  <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>

  <script type="text/javascript">
  
    var gmap = null;

    function initialize() {
      gmap = new GMap2(document.getElementById("gmap"));
      var centerat = new GLatLng(0,0);
      gmap.addControl(new GLargeMapControl());
      gmap.addControl(new GMapTypeControl());
      gmap.setCenter(centerat, 1);
      var dynamicMap = new esri.arcgis.gmaps.DynamicMapServiceLayer("http://map.entrix.com/ArcGIS/rest/services/Atlases/USA/MapServer", null, 0.75, dynmapcallback);
    }

    function dynmapcallback(mapservicelayer) {
      gmap.addOverlay(mapservicelayer);
    }

  </script>

</head>
<body onload="initialize();" onunload="GUnload();">
<div id="gmap" style="width: 500px; height:500px;"></div>
</body>
</html>
0 Kudos
5 Replies
JeffPace
MVP Alum
I am not sure you can use albers projection with google.

Can you try redoing your service in web mercator aux sphere ??

You don't need top change your data, just change the data frame projection in the msd, restart your service and clear your rest cache.
0 Kudos
CurtWalker
New Contributor
I am not sure you can use albers projection with google.

Can you try redoing your service in web mercator aux sphere ??

You don't need top change your data, just change the data frame projection in the msd, restart your service and clear your rest cache.


Ok I opened the MXD, changed data frame projection to Web Mercator Auxiliary Sphere, saved, restarted the service and cleared cache.  Still does not overlay.

I also contacted ESRI tech support.  They weren't sure which project it needed to be, but I pointed out that the ESRI dynamic map service that is used in the Knowledge Base tutorial is WKID: 4326 (WGS84).  I have tried using a service in this projection as well but it does not overlay.
0 Kudos
NianweiLiu
Occasional Contributor II
Do you have your own google key? Simply replace map service URL to yours won't work because the sample's key is registered with Esri's domain.
If you do not have an existing key you may out of luck because Google may no longer issue keys for v2 API (deprecated for 2+ years now). You should really avoid this approach and look for alternatives.
0 Kudos
CurtWalker
New Contributor
Do you have your own google key? Simply replace map service URL to yours won't work because the sample's key is registered with Esri's domain.
If you do not have an existing key you may out of luck because Google may no longer issue keys for v2 API (deprecated for 2+ years now).


My code above doesn't use the sample key for ESRI, it uses my key registered to my domain.  You got me curious about version 2 though, so I generated a new key and switched to version 3 (See updated code below).  This did not fix the problem.

The problem really has nothing to do with the Google API.  It's an issue with ArcGIS and the dynamic service, at least that is currently the theory of ESRI technical support.  Still awaiting resolution...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
  <title>ArcGIS JavaScript Extension for the Google Maps API Example</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <script src="http://maps.google.com/maps?file=api&v=3&key=AIzaSyDZlBLE1DNYj8IgCIP4JzkEVs8bclKfr90" type="text/javascript"></script>
  <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>

  <script type="text/javascript">
  
    var gmap = null;

    function initialize() {
      gmap = new GMap2(document.getElementById("gmap"));
      var centerat = new GLatLng(28,-82.5);
      gmap.addControl(new GLargeMapControl());
      gmap.addControl(new GMapTypeControl());
      gmap.setCenter(centerat, 10);
      var dynamicMap = new esri.arcgis.gmaps.DynamicMapServiceLayer("http://map.entrix.com/ArcGIS/rest/services/Atlases/USA/MapServer", null, 1.0, dynmapcallback);
    }

    function dynmapcallback(mapservicelayer) {
      gmap.addOverlay(mapservicelayer);
    }

  </script>

</head>
<body onload="initialize();" onunload="GUnload();">
<div id="gmap" style="width: 500px; height:500px;"></div>
</body>
</html>
0 Kudos
NianweiLiu
Occasional Contributor II
Question was answered in a different thread. Your map server's output directory is using host name, not a public domain name. The extension uses json output directory, that's why you are not seeing the image. The more recent JS API (and service directory) use direct image output thus hide the problem in the G extension.
0 Kudos