aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-04-10 15:41:22 -0300
committerSilvio <silvio@socioambiental.org>2013-04-10 15:41:22 -0300
commit3b84e12ef966cc8cad57f9187ce77adc9f0e001f (patch)
tree71100ca48694a85b314f9e408a38e2ccfa65261f
parent4c24ddab618e817012b8edcdc78e8cccb1793939 (diff)
downloadgmap_arcgis_js-3b84e12ef966cc8cad57f9187ce77adc9f0e001f.tar.gz
gmap_arcgis_js-3b84e12ef966cc8cad57f9187ce77adc9f0e001f.tar.bz2
Merging fitToBoundsOfQuery with showPolygonFromQuery
-rw-r--r--gmap_arcgis.js49
1 files changed, 15 insertions, 34 deletions
diff --git a/gmap_arcgis.js b/gmap_arcgis.js
index 5689e6b..5b7bf69 100644
--- a/gmap_arcgis.js
+++ b/gmap_arcgis.js
@@ -90,29 +90,6 @@ function gmapArcgis(config) {
return params.overlay;
},
- // TODO: merge with fitToBoundsOfQuery
- // Add polygons from a custom query
- showPolygonFromQuery: function(params) {
- var self = this;
- var layer = new gmaps.ags.Layer(params.uri);
- var query = {
- returnGeometry: true,
- geometryType: 'esriGeometryPolygon',
- where: params.where,
- outFields: '*',
- };
-
- layer.query(query, function(fset) {
- var fs = fset.features;
- var feature = fs[0];
- params.overlay = feature.geometry[0];
-
- params.overlay.setMap(self.map);
- });
-
- return params.overlay;
- },
-
// Add an identify callback to a layer
identifyPolygon: function(params) {
// See https://google-maps-utility-library-v3.googlecode.com/svn/trunk/arcgislink/examples/identify.js
@@ -457,7 +434,7 @@ function gmapArcgis(config) {
// Center and zoom map to fit the polygon resulting from a query
// Optinally show the resulting polygon.
- fitToBoundsOfQuery: function(params, show) {
+ showPolygonFromQuery: function(params) {
var self = this;
var layer = new gmaps.ags.Layer(params.uri);
var query = {
@@ -468,20 +445,24 @@ function gmapArcgis(config) {
};
layer.query(query, function(fset) {
- var fs = fset.features;
- var feature = fs[0];
- var bounds = feature.geometry[0].getBounds();
- var zoom = self.getZoomByBounds(bounds);
- var center = bounds.getCenter();
+ var fs = fset.features;
+ var feature = fs[0];
+ params.overlay = feature.geometry[0];
- self.map.setZoom(zoom);
- self.map.setCenter(center);
+ // Fit map to polygon bounds
+ if (params.fitBounds != undefined && params.fitBounds == true) {
+ var bounds = params.overlay.getBounds();
+ var zoom = self.getZoomByBounds(bounds);
+ var center = bounds.getCenter();
- if (show == true) {
- feature.geometry[0].setMap(self.map);
+ self.map.setZoom(zoom);
+ self.map.setCenter(center);
}
- params.overlay = feature.geometry[0];
+ // Show polygon
+ params.overlay.setMap(self.map);
+
+ return params.overlay;
});
},
}