Geo Map markers in impossible places


#1

Hello community I have a Geo Map where I want to put markers in the dropoff places of taxis trips of the Chicago Taxi Trips public data set, but there are some markers that evidently are not in Chicago. This is the code that I am using to render the graphic. How can I fix this?

/* Configuration code for this widget */
let provider = cf.provider("Elastic Demo");
let source = provider.source('chicago_taxi_trips');
// Add Metrics
let metricCount = new cf.Metric("count");
// Add fields to data source.
let myData = source
			.fields("dropoff_latitude", "dropoff_longitude", "fare")
			// Metrics (do not remove this line)
			.metrics(metricCount);
// Define chart options
let myChart = myData.graph("Geo Map")
			.set("center", [24.607069137709708,-43.33007812500001])
			.set("zoom", 3)
			.execute();

Thanks


#2

hi, @pepe I think that you have data records with no latitude and longitude information. In those cases, the chart assigns to that records [0,0] and that’s why you see markers on the center of the map. What you can do is declare a staticFilter that discard those records with invalid latitude and longitude, to avoid showing them in the map. For example:

/* Configuration code for this widget */
let provider = cf.provider("Elastic Demo");
let source = provider.source('chicago_taxi_trips');
// Add Metrics
let metricCount = new cf.Metric("count");
// Add fields to data source.
let myData = source
			.fields("dropoff_latitude", "dropoff_longitude", "fare")
			// Metrics (do not remove this line)
			.metrics(metricCount);
let staticFilter = cf.Filter('dropoff_latitude')
                .operation('NOT IN')
                .value([0, 'null']);
// Define chart options
let myChart = myData.graph("Geo Map")
			.set("center", [24.607069137709708,-43.33007812500001])
			.set("zoom", 3)
			.staticFilters(staticFilter)
			.execute();

Let me know if that fixes your problem. Best regards.