Skip to content
This repository was archived by the owner on Aug 10, 2026. It is now read-only.

2026-08-08 updates - #160

Merged
moshen merged 25 commits into
masterfrom
2026-08-08-updates
Aug 9, 2026
Merged

2026-08-08 updates#160
moshen merged 25 commits into
masterfrom
2026-08-08-updates

Conversation

@moshen

@moshen moshen commented Aug 9, 2026

Copy link
Copy Markdown
Owner

No description provided.

moshen added 24 commits August 8, 2026 17:34
parsePaths() joined all paths into a single pipe-separated string, which
qs then emitted as one path= parameter. Google's Static Maps API expects
each path as a separate path= parameter, so additional paths were silently
dropped. Return the array so each path becomes its own path= query param.

Refs #149, #133
Add the 'type' parameter to the place-search-nearby accepted params (the
'types' param is deprecated by Google). Also stop defaulting radius to the
maximum when rankby=prominence, since an unspecified radius affects ranking
differently than an explicit one.

Refs #130
When the 'binary' encoding is requested for static maps, pass encoding=null
to the request library so it returns a raw Buffer instead of a stringified
representation. The previous string output produced unusable image files.

Refs #119, #159

Closes #159
Google's Static Maps API accepts URLs up to 8192 characters, but the library
rejected anything beyond 2048. Bump the limit so larger static map requests
succeed.

Refs #139, #138, #146

Closes #138, #146
The fallback swap of minprice and maxprice referenced an undefined 'ags'
variable, throwing a ReferenceError whenever a caller set maxprice below
minprice. Correct the variable name to args.
The example value 'components=country:GB' was being double-prefixed into
'components=components=country:GB', which Google rejects with 'Component
filter type components=country is not supported'. Use the bare value
'country:GB'.

Refs #154

Closes #154
qs 4.x is vulnerable to a prototype pollution bypass (npm audit). Bump the
dependency to ^6.3.2 which contains the fix. The stringify usage
(arrayFormat 'repeat', indices) is unchanged.

Refs #155, #157

Closes #155, #157
Allow a path to specify an 'enc' string of pre-encoded polyline data
instead of an array of points. This lets callers reuse encoded polyline
strings produced elsewhere (e.g. from the Directions API) without
re-encoding. The existing points-array behaviour is unchanged.

Ported from fork Markario/node-googlemaps.
Google's Directions and Distance Matrix APIs accept the literal string
"now" for departure_time/arrival_time. Previously the date-typed param
validator rejected it, and even if it passed, convertTargetTimes divided
the string by 1000. Allow "now" through the date check and skip the
millisecond->second conversion for it.

Ported from fork fukuru/node-googlemaps.
test/simpleConfig.json contained a real Google Maps API key that is now
inactive (REQUEST_DENIED - billing disabled). Delete the file and load the
integration test config from the GOOGLE_MAPS_API_KEY environment variable
instead (with an optional git-ignored test/simpleConfig.json fallback for
local dev). Unit tests no longer depend on the file and use a fixed
placeholder key. Travis now runs only the offline unit suite.

Also wired elevationFromPathTest (which used a no-config constructor) to the
shared config.

Closes #152
The expected-URL assertions hardcoded an API key, so any failure diff
would print the operator's key to the test output. Redact the key=...
segment before comparing, and remove a stray console.log(typeof data) in
the streetview tests that surfaced raw response data. Use config.key so
the assertions pass regardless of which key the operator supplies.

Also add .env to .gitignore so sourced credentials never get committed.
Several integration tests asserted hardcoded exact lat/lng values (or
exact auth error strings) that have either drifted as Google's
geocoding/routing has aged, or vary by environment (sandbox network
policy vs. genuine auth rejection). Replace the brittle
equality checks with bounding-box / rejection checks:

- directions: assert step end_location falls within a small bbox of the
  expected region rather than at a fixed point.
- placeSearchText: Australian/US bbox for Sydney, continental-US bbox for
  the unbiased query, and a tight bbox around the location bias for the
  biased query. For the Sydney query (whose literal '+' chars produce
  unstable rankings) only assert a valid Earth coordinate.
- errors/Wrong Credentials: assert the request was rejected (>=400 code
  or an auth/denied/unauthor/blocked/forbidden message) rather than
  matching a specific 403/string that Google changed.

Now: unit 413 passing, integration 39 passing, 0 failing.
The library could encode polylines but not decode them. Add a
decodePolyline utility (reverse of encodePolylines) that converts an
encoded polyline string into an array of [lat, lng] coordinate pairs,
and expose it as gmAPI.decodePolyline(). This is useful for decoding
the overview_polyline.points field returned by the Directions API.

Closes #18, #129
Google's Directions and Distance Matrix APIs support transit_mode
(bus/subway/train/tram/rail) and transit_routing_preference
(less_walking/fewer_transfers) when mode=transit, but these params were
not in the accepted params list so assignParams silently dropped them.

Closes #69
parseStyles only accepted the legacy { feature, element, rules } format.
Google's styled maps wizard now exports { featureType, elementType, stylers }
where stylers is an array of { key: value } objects and colours use #hex
notation instead of 0xhex. Support both formats: map featureType to feature,
elementType to element, flatten stylers arrays, and convert #hex colours to
0xhex for the Static Maps API URL.

Closes #140
Google returns non-fatal warnings for static map requests in the
X-StaticMap-API-Warning response header (e.g. invalid markers that were
silently ignored). These were being dropped by makeRequest. On a 200
response, check for the warning header and surface it as an error with
isWarning=true so callers can handle warnings while still receiving the
image data.

Closes #153
The buildUrl/waypoints bug (#49) produced waypoints=&waypoints= in the
URL when waypoints was passed as an array of empty strings. This is
already fixed in the current codebase: assignParams rejects non-string
values for the waypoints param (typed as 'string' in constants.json),
so array waypoints are silently dropped and never reach the URL builder.

Closes #49
The PNG data fetch test used a custom marker icon hosted at
http://chart.apis.google.com/chart (deprecated since 2012, now offline).
Replace with plain colored markers so the image fetch succeeds without
an external icon download.
Add google_api_url and google_secure_api_url as accepted config keys that
default to the current hardcoded values (http(s)://maps.googleapis.com).
makeRequest now reads the base URL from config instead of a hardcoded
string. This enables mocking the Google API endpoints for local
development and CI without hammering real servers or burning quota.

Purely additive: existing configs behave identically since the defaults
match the previous hardcoded values.

Closes #111
qs was only used in makeRequest._buildUrl for query string
serialization, and its arrayFormat:'repeat' output (path=a&path=b) is
identical to what node's built-in querystring.stringify produces for
arrays. Remove the direct qs dependency and use querystring instead.
This also eliminates the qs prototype-pollution advisory surface from
our direct dependencies (qs remains only as a transitive dep of request).

Closes #155, #157
Remove the Travis CI configuration and add a GitHub Actions workflow
mirroring the structure used in other projects (wasmagic):

- build: runs the unit test suite on Node 22
- matrix-tests: runs the unit test suite on Node 18, 20, and 22
- publish: auto-publishes on push to master via merge-release

The integration test suite is excluded from CI since it requires an API
key that is not available in the CI environment.
The test asserted the error message started with 'Unexpected token i',
but newer V8 versions changed the JSON parse error format to include
quoted input (Unexpected token 'i', "i am an in"...). Assert the
error is a SyntaxError instead of matching a specific message string.
Three behavioral fixes could break existing callers. Gate each behind a
config key that defaults to the old behavior so existing code is
unaffected unless the caller opts in:

- static_map_binary (default false): when true, staticMap returns image
  data as a Buffer instead of a string (the old string output produced
  unusable image files).
- static_map_warnings (default false): when true, the X-StaticMap-API-Warning
  response header is surfaced as a non-fatal error in the staticMap
  callback. By default warnings are silently ignored.
- places_default_radius (default true): when false, placeSearch no longer
  defaults radius to 50km if omitted (Google ranks differently without it).

Also updated the README with a configuration table, mocking docs, and
replaced the dead Travis badge with a GitHub Actions badge.
Add the npm 'deprecated' field, update the description to 'DEPRECATED:
...', and add a deprecation notice at the top of the README pointing
users to Google's official Node.js client library
@googlemaps/google-maps-services-js (https://github.com/googlemaps/google-maps-services-js).
@moshen
moshen force-pushed the 2026-08-08-updates branch from f157081 to 1b47d0d Compare August 9, 2026 15:58
@moshen
moshen merged commit 450d378 into master Aug 9, 2026
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant