Skip to content

Instantly share code, notes, and snippets.

View dbouwman's full-sized avatar
😎
Hubbin it up @ Esri

Dave Bouwman dbouwman

😎
Hubbin it up @ Esri
View GitHub Profile
@dbouwman
dbouwman / geocode.js
Last active September 6, 2018 18:37
Snipped showing geocoding w/ jquery and the Esri geocode service
geocodeAddress: function (data) {
console.log('Geocoder called with ' + data);
//although there is a dijit that can do this search
//it's just a simple ajax call, so we will just use jquery
var url = 'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find';
this.layout.showSpinner();
$.ajax(url, {
data: {
text: data,
f: 'json',
@dbouwman
dbouwman / gist:5131145
Created March 11, 2013 00:22
Geocode results handler - if we get one match back, it just raises the event, if we get any other number, we send the results to a collection, and
geocodeResultsHandler:function(data,status,jqXHR){
console.log('Got Geocode Results...');
console.dir(data);
//get the count returned
var foundCount = data.locations.length;
if(foundCount === 1){
var loc = data.locations[0];
//hide the ui and zoom to the location
//create a simple point Object
@dbouwman
dbouwman / map-init-snippet.js
Last active December 14, 2015 18:39
Snipped of the EsriMapModule.js showing how the basemaps and operational layers are added to the map
initBaseLayers: function (basemaps) {
console.log('Map:Controller:initBaseLayers');
_.each(basemaps, function(layer){
switch(layer.type){
case 'ArcGISTiledMapServiceLayer':
var lyr = new esri.layers.ArcGISTiledMapServiceLayer(layer.url,
{
id: 'basemap_' + layer.label,
visible: layer.visible
});
@dbouwman
dbouwman / RouterModule.js
Last active December 15, 2015 06:19
Router Module
/*global gmm */
if (!this.gmm || typeof this.gmm !== 'object') {
this.gmm = {};
}
(function () {
'use strict';
gmm.Viewer.module('RouterModule', function (Mod, Viewer, Backbone, Marionette, $, _) {
//==================================
//initializer called on Viewer.start(options)
@dbouwman
dbouwman / EsriMapModuleSnippet.js
Created March 21, 2013 18:56
Snipped of the EsriMapModule showing the new event handlers, and
initMap: function (mapConfig) {
console.log('Map:Controller:initMap');
var initialExtent = new esri.geometry.Extent(mapConfig.initialExtent);
this.map = new esri.Map("map", {
extent: initialExtent,
maxZoom: 15
});
@dbouwman
dbouwman / FireConfig.js
Created March 22, 2013 03:56
snippet of the object we pass along with the FireLayer:ConfigChanged event
{
url:'http://wildfire.cr.usgs.gov/ArcGIS/rest/services/geomac_dyn/MapServer',
model:
{
name:'2012 Fires',
layerId:7,
perimeterLayerId:18,
defn:"year_='2012'"
}
}
@dbouwman
dbouwman / getLayerDefinitionSnipped.js
Created March 22, 2013 04:14
Snippet showing the layer definition function
getFireLayerDefinition: function(){
var defn = {
"geometryType": "esriGeometryPoint",
"objectIdField": "objectid",
"spatialReference":{"wkid":102100},
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriPMS",
@dbouwman
dbouwman / showFiresSnippet.js
Created March 22, 2013 04:19
Snippet showing how I created a feature layer from an array of features
showFires:function(featureArray){
//remove the firelayer if it's in the map
var lyr = this.map.getLayer("fireLayer");
if(lyr){
this.map.removeLayer(lyr);
}
//setup the definition for the layer
//this includes the renderer
var layerDefinition = this.getFireLayerDefinition();
var featureCollection = {
@dbouwman
dbouwman / RouterOnMapLoadedSnipped.js
Created March 22, 2013 04:28
onMapLoaded handler in Router. I do this so that we wait until the map is ready, and THEN dispatch events telling is how to re-hydrate it's state
onMapLoaded:function(){
//ok, now that we have a map we can link up some events
Viewer.vent.on('FireLayer:ConfigChanged',this.setYear);
//and if we have values passed in on the url, raise events
if(this.urlValues){
Viewer.vent.trigger('FireLayer:ConfigChanged', this.urlValues.yearData);
Viewer.vent.trigger('Map:ShowPerimeters',this.urlValues.yearData);
Viewer.vent.trigger('Navbar:ChangeItemName',this.urlValues.yearData.model.name);
Viewer.vent.trigger('Map:CenterAtLatLongAndZoom', {
x:this.urlValues.x,
//NOTE THIS IS A SNIPPET OF CODE! IT WILL NOT RUN LIKE THIS! STUFF IT INTO A CLASS
IFeatureClass featureClass = Helper.OpenFromFGDB(@"C:\data\Historical_Routes.gdb", fcName);
Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(t);
ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory;
IProjectedCoordinateSystem webMercatorSR = srFact.CreateProjectedCoordinateSystem((int)esriSRProjCS2Type.esriSRProjCS_WGS1984SphereWebMercator);
IQueryFilter queryFilter = new QueryFilterClass();