Skip to content

Not a LatLngBounds or LatLngBoundsLiteral #1934

@randal923

Description

@randal923

I am getting this error: "not a LatLngBounds or LatLngBoundsLiteral: unknown property northeast"

I am using the directions API and just using the DirectionsRenderer that this library provides. The response I get from the Directions is API is as follows:

{
  geocoded_waypoints: [],
  routes: [
    bounds: {
      northeast: { lat: number, lng: number },
      southwest: { lat: number, lng: number }
    }
  ]
}

The DirectionsRenderer requires a request object though. So I modified the above response before passing it down to the DirectionsRenderer component. It turned out like this:

{
  geocoded_waypoints: [],
  request: {
    origin: {
      location: { lat: number, lng: number }
    },
    destination: {
      location: { lat: number, lng: number }
    },
    travelMode: 'DRIVING' as any
  },
  routes: []
}

When I pass this object down to the DirectionsRendere I get that error though.
"not a LatLngBounds or LatLngBoundsLiteral: unknown property northeast"

I took a look at the DirectionsRoute typing and it required a LatLngBounds type.

/**
 * Constructs a rectangle from the points at its south-west and north-east corners.
 * @see {@link https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngBounds.constructor Maps JavaScript API}
 */
constructor(sw?: LatLng | LatLngLiteral, ne?: LatLng | LatLngLiteral);

I thought the issue was that in the original response from the directions API it was written southwest and northeast instead of sw and ne. So I changed my object to reflect that and it still did not work. Then I took a look at the response from the DirectionsService that this library provides and I saw this object:

bounds: {
  Wa: {
    i: number,
    j: number
  },
  Ra: {
    i: number,
    j: numbeer
  }
}

I tried emulating this nomeclature and I still got the same error. I am confused as to what I should do here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions