diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index a06d5ac60e21..b85115743868 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -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) { diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index 1c4a8b93fcac..0fba33756073 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -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() {