Skip to content

Commit

Permalink
Merge pull request #4452 from AnalyticalGraphicsInc/handle-missing-image
Browse files Browse the repository at this point in the history
Handle missing maki icons in GeoJson load
  • Loading branch information
Hannah authored Oct 19, 2016
2 parents d02bdd2 + ae9272d commit fd90be0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Source/DataSources/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,25 @@ define([
canvasOrPromise = dataSource._pinBuilder.fromColor(color, size);
}

dataSource._promises.push(when(canvasOrPromise, function(dataUrl) {
var billboard = new BillboardGraphics();
billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.BOTTOM);
billboard.image = new ConstantProperty(dataUrl);
var billboard = new BillboardGraphics();
billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.BOTTOM);

// Clamp to ground if there isn't a height specified
if (coordinates.length === 2) {
billboard.heightReference = HeightReference.CLAMP_TO_GROUND;
}
// Clamp to ground if there isn't a height specified
if (coordinates.length === 2) {
billboard.heightReference = HeightReference.CLAMP_TO_GROUND;
}

var entity = createObject(geoJson, dataSource._entityCollection, options.describe);
entity.billboard = billboard;
entity.position = new ConstantPositionProperty(crsFunction(coordinates));

var promise = when(canvasOrPromise).then(function(image) {
billboard.image = new ConstantProperty(image);
}).otherwise(function() {
billboard.image = new ConstantProperty(dataSource._pinBuilder.fromColor(color, size));
});

var entity = createObject(geoJson, dataSource._entityCollection, options.describe);
entity.billboard = billboard;
entity.position = new ConstantPositionProperty(crsFunction(coordinates));
}));
dataSource._promises.push(promise);
}

function processPoint(dataSource, geoJson, geometry, crsFunction, options) {
Expand Down
22 changes: 22 additions & 0 deletions Specs/DataSources/GeoJsonDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,28 @@ defineSuite([
});
});

it('Works with point geometry and unknown simplystyle', function() {
var geojson = {
type : 'Point',
coordinates : [102.0, 0.5],
properties : {
'marker-size' : 'large',
'marker-symbol' : 'notAnIcon',
'marker-color' : '#ffffff'
}
};

var dataSource = new GeoJsonDataSource();
return dataSource.load(geojson).then(function() {
var entityCollection = dataSource.entities;
var entity = entityCollection.values[0];
expect(entity.billboard).toBeDefined();
return when(dataSource._pinBuilder.fromColor(Color.WHITE, 64)).then(function(image) {
expect(entity.billboard.image.getValue()).toBe(image);
});
});
});

it('Works with multipoint geometry', function() {
var dataSource = new GeoJsonDataSource();
return dataSource.load(multiPoint).then(function() {
Expand Down

0 comments on commit fd90be0

Please sign in to comment.