Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing maki icons in GeoJson load #4452

Merged
merged 1 commit into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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