GWT-Maps-V3-Api icon indicating copy to clipboard operation
GWT-Maps-V3-Api copied to clipboard

Exception Creating a Heat Map from non-encoded values

Open joni-jones opened this issue 11 years ago • 4 comments

I'm trying to create a heat map using points sourced from a database. This is my code:

JsArray<LatLng> points = JsArray.createArray().cast();
for(int i = 0; i < count; i ++){
        GPSCoordinate point = routeList.get(i);
            double latitude = Double.parseDouble(point.getLatitude());
            double longitude = Double.parseDouble(point.getLongitude());
            points.push(LatLng.newInstance(latitude, longitude));
}
HeatMapLayer heatMapLayer = HeatMapLayer.newInstance(options);
heatMapLayer.setData(points);

But i get this exception: a[Qb] is not a function.

If I add:

String path = EncodingUtils.encodePath(points);
points = EncodingUtils.decodePath(path);

Before:

heatMapLayer.setData(points);

All works fine. But I plan to use WeightedLocation and this solution not be working.

joni-jones avatar Feb 27 '13 12:02 joni-jones

@joni-jones to isolate that this is not the code filling the points, can you confirm this behavior with hardcoded LatLngs? Just to make sure NULL or similar is not being passed in. That way I've at least got a test case without GPSCoordinate to work with. Thanks.

twistedpair avatar Feb 27 '13 16:02 twistedpair

Thanks for your answer. I'm also tried 'hardcode' single LatLng point and get this exception. Also i checked JsArray of points it not empty.

joni-jones avatar Feb 27 '13 17:02 joni-jones

If I'm call this code:

JsArray<LatLng> newPoints = JsArray.createArray().cast();
newPoints.push(LatLng.newInstance(12.936992205764442, 77.62094830425235));
HeatMapLayer heatMapLayer = HeatMapLayer.newInstance(options);
heatMapLayer.setData(newPoints);

I'm get exception, but if add:

String path = EncodingUtils.encodePath(newPoints);
newPoints = EncodingUtils.decodePath(path);

Heat showing on the map.

joni-jones avatar Feb 27 '13 17:02 joni-jones

@joni-jones Thanks for confirming this. I'll check it out when I get home tonight.

twistedpair avatar Feb 27 '13 17:02 twistedpair