Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Hubbin it up @ Esri

Dave Bouwman dbouwman

😎
Hubbin it up @ Esri
View GitHub Profile
@dbouwman
dbouwman / geocode.js
Last active Sep 6, 2018
Snipped showing geocoding w/ jquery and the Esri geocode service
View geocode.js
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 Mar 11, 2013
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
View gist:5131145
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 Dec 14, 2015
Snipped of the EsriMapModule.js showing how the basemaps and operational layers are added to the map
View map-init-snippet.js
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
});
View RouterModule.js
/*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 Mar 21, 2013
Snipped of the EsriMapModule showing the new event handlers, and
View EsriMapModuleSnippet.js
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 Mar 22, 2013
snippet of the object we pass along with the FireLayer:ConfigChanged event
View FireConfig.js
{
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 Mar 22, 2013
Snippet showing the layer definition function
View getLayerDefinitionSnipped.js
getFireLayerDefinition: function(){
var defn = {
"geometryType": "esriGeometryPoint",
"objectIdField": "objectid",
"spatialReference":{"wkid":102100},
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriPMS",
@dbouwman
dbouwman / showFiresSnippet.js
Created Mar 22, 2013
Snippet showing how I created a feature layer from an array of features
View showFiresSnippet.js
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 Mar 22, 2013
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
View RouterOnMapLoadedSnipped.js
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,
View LRS-Lookup.cs
//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();
You can’t perform that action at this time.