-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ecd708
commit 85fd89e
Showing
1 changed file
with
33 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,35 @@ | ||
var exampleDebug = {}; | ||
|
||
// Run after the DOM loads | ||
$(function () { | ||
'use strict'; | ||
|
||
var capitals; | ||
$.when( | ||
/* Fetch capitals */ | ||
$.ajax({url: 'capitals.json'}).done(function (resp) { | ||
capitals = resp; | ||
}) | ||
).then(function () { | ||
|
||
// Set map defaults to a reasonable center and zoom level | ||
var mapParams = { | ||
node: '#map', | ||
center: {x: 0, y: 0}, | ||
zoom: 2.5, | ||
clampBoundsX: false, | ||
clampBoundsY: false, | ||
clampZoom: false, | ||
discreteZoom: false | ||
}; | ||
// Set the tile layer defaults | ||
var layerParams = { | ||
zIndex: 0, | ||
minLevel: 4, | ||
keepLower: true, | ||
wrapX: false, | ||
wrapY: false | ||
}; | ||
// Create a map object | ||
var map = geo.map(mapParams); | ||
// Add the tile layer with the specified parameters | ||
var osmLayer = map.createLayer('osm', layerParams); | ||
// Set the vtk feature layer params | ||
var vtkLayerParams = { | ||
renderer: 'vtkjs' | ||
}; | ||
// Create a vtk point feature layer | ||
var vtkLayer = map.createLayer('feature', vtkLayerParams); | ||
var pointFeature = vtkLayer | ||
.createFeature('point', { | ||
selectionAPI: true, | ||
style: { | ||
radius: 100, // sphere radius (~0.1km) | ||
fillColor: 'red', | ||
fillOpacity: function () { | ||
return Math.random(); | ||
} | ||
} | ||
}) | ||
.data(capitals) // bind data | ||
.position(function (d) { | ||
return {x: d.longitude, y: d.latitude}; // position accessor | ||
}) | ||
.draw(); | ||
|
||
// Make variables available as a global for easier debug | ||
exampleDebug.map = map; | ||
exampleDebug.mapParams = mapParams; | ||
exampleDebug.layerParams = layerParams; | ||
exampleDebug.osmLayer = osmLayer; | ||
exampleDebug.vtkLayerParams = vtkLayerParams; | ||
exampleDebug.vtkLayer = vtkLayer; | ||
exampleDebug.pointFeature = pointFeature; | ||
$.ajax({url: 'capitals.json'}).done(function (capitals) { | ||
// Create a map object with reasonable center and zoom level | ||
var map = geo.map({ | ||
node: '#map', | ||
center: {x: 0, y: 0}, | ||
zoom: 2.5, | ||
clampBoundsX: false, | ||
clampBoundsY: false, | ||
clampZoom: false, | ||
discreteZoom: false | ||
}); | ||
// Add the tile layer with the specified parameters | ||
map.createLayer('osm', { | ||
zIndex: 0, | ||
minLevel: 4, | ||
keepLower: true, | ||
wrapX: false, | ||
wrapY: false | ||
}); | ||
// Create a vtk point feature layer | ||
var vtkLayer = map.createLayer('feature', { renderer: 'vtkjs' }); | ||
vtkLayer.createFeature('point', { | ||
selectionAPI: true, | ||
style: { | ||
radius: 100, // sphere radius (~0.1km) | ||
fillColor: 'red', | ||
fillOpacity: Math.random | ||
} | ||
}) | ||
.data(capitals) // bind data | ||
.position(function (d) { | ||
return {x: d.longitude, y: d.latitude}; // position accessor | ||
}) | ||
.draw(); | ||
}); |