Select to view content in your preferred language

Is it possible to use google maps as a basemap layer AND use a feature layer?

2706
6
09-29-2011 12:32 PM
LizDaRos
Regular Contributor
I'm using the Google Maps Layer for ArcGIS JavaScript API-
<script type="text/javascript" src="http://gmaps-utility-gis.googlecode.com/svn/tags/gmapslayer/1.0/src/gmapslayer_compiled.js" ></script>
var gMapLayer = new gmaps.GoogleMapsLayer({visible:false, id:'googlemaps'});
map.addLayer(gMapLayer);
I'm also using a feature layer which seems to work but when panning around the map my featurelayer pans farther then the google maps layer. Is there something I can change to correct this?
Here's a sample of what is happening-just pan around and notice the feature points don't move with the google map:

http://gis.manchesterct.gov/JavaScriptAPI/Google.html
0 Kudos
6 Replies
HemingZhu
Frequent Contributor
I'm using the Google Maps Layer for ArcGIS JavaScript API-
<script type="text/javascript" src="http://gmaps-utility-gis.googlecode.com/svn/tags/gmapslayer/1.0/src/gmapslayer_compiled.js" ></script>
var gMapLayer = new gmaps.GoogleMapsLayer({visible:false, id:'googlemaps'});
map.addLayer(gMapLayer);
I'm also using a feature layer which seems to work but when panning around the map my featurelayer pans farther then the google maps layer. Is there something I can change to correct this?
Here's a sample of what is happening-just pan around and notice the feature points don't move with the google map:

http://gis.manchesterct.gov/JavaScriptAPI/Google.html


Try this:  var map = new esri.Map("map", {displayGraphicsOnPan:false});
0 Kudos
LizDaRos
Regular Contributor
Thanks for the suggestion, I had tried that earlier but no luck. Once the pan ends the graphics/points are set in a different area.
0 Kudos
DavidElies
Deactivated User
I'm having a similar problem but with an ArcGISDynamicMapServiceLayer.  If the google maps layer is the base layer, I have the same problem Lizd is having.  If I use the ESRI World-Imagery layer as the base layer and hide it behind the google maps layer, it only screws up if the AGDMSLayer is shown before a zoom.  After a zoom (whether the AGDMSLayer was visible or not), it has no problem.  It seems like it is using the wrong extent to query and display the map.  Is this a problem with the gmaps.GoogleMapsLayer?  Is this even supported by ESRI?  Any insights would be helpful.
0 Kudos
NianweiLiu
Frequent Contributor
It's possible.
The script you use is a little old, I recommend you use the new version at http://www.arcgis.com/home/item.html?id=a84d64b0d1404366a02da714ca59d61f.

When you drag the map, the graphics maybe moving in a different pace than the background google map, that's a limitation of how this lib is implemented due to Google license restriction regarding direct access to tiles. Due to unknown internals in Esri API, the style transformation is applied differently. However, when you stop pan (extentChange event), your graphics should be align correctly in the right place.

I've attached a zipped html file with the new version of the lib, based on your page, all seem working as expected.
0 Kudos
NianweiLiu
Frequent Contributor
No it is not supported by Esri. It's just a lib in the code gallery, just like the old arcscripts stuff. Normally you need to dig out into the code if it is not work straight for you.
0 Kudos
LizDaRos
Regular Contributor
Thanks Nianwei Liu. I thought I kinda had it working before, it seemed like the initial extent was the problem so I fixed that and also added in a few parameters like draggable:false.
I just tried your updated code and so far it seems to work fine. I would like to get the little yellow streetview guy out of the top left corner though. Do you know how to hide that? I did logo:false but that just gets rid of the Google logo on the bottom left corner.
0 Kudos