Select to view content in your preferred language

Setting the initial map extent in the Google Maps API

3494
1
12-15-2010 07:56 AM
PaulHuffman
Frequent Contributor
I created a map app with the Google Map API to display one of my map services on a Google Map basemap.  I'd like to have the map app start with a map extent closer to the extent of my map service rather than the whole globe.  Sure, Google Map API is completely documented and I can find that the initial map extent is a property of the class esri.arcgis.gmaps.DynamicMapServiceLayer But I'm having trouble figuring out what the syntax is to add a property to the class is.  Are there any examples online? 

When I did this with an ESRI online basemap my initial extent was set with
var initExtent = new esri.geometry.Extent({"xmin":-13785833.373418408,"ymin":5680675.316201857,"xmax":-13006175.684909647,"ymax":6045127.06706556,"spatialReference":{"wkid":102100}});
        map = new esri.Map("map",{extent:initExtent});


I tried this with the Google MAP API but I get an syntax error right away in my IDE:
var dynamicMap = new esri.arcgis.gmaps.DynamicMapServiceLayer
        ("http://host119.yakama.com/ArcGIS/rest/services/facilitiesWGSWebMer2/MapServer",
        null, 0.75, dynmapcallback, initialExtent{"xmin":-13785833.373418408,"ymin":5680675.316201857,"xmax":-13006175.684909647,"ymax":6045127.06706556,"spatialReference":{"wkid":102100}});
0 Kudos
1 Reply
PaulHuffman
Frequent Contributor
I found some good examples of dealing with the Goggle Map API at
http://code.google.com/apis/maps/documentation/javascript/v2/examples/index.html
The example at
http://code.google.com/apis/maps/documentation/javascript/v2/examples/map-markers.html
was enough to show me how to set the map extent when generating the new
Google Map instance, rather than when adding the
DynamicMapServiceLayer.  Now I have something that is working better.
0 Kudos