Registry / maps / mapkit-typescript

mapkit-typescript

JSON →
library5.18.2jsnpmunverified

TypeScript type definitions for Apple MapKit JS (v5.18.2). This package provides full type declarations for the MapKit JS library, enabling static type checking and autocompletion in TypeScript projects. Maintained by the community, updated irregularly to match MapKit JS releases. Key differentiator: it is the primary source of TypeScript types for MapKit JS, as Apple does not ship official types.

npm install mapkit-typescript
INSTALL
IMPORT
SIG · MAPKIT-TYPESCRIPT
M
mapkit-typescript
mapsjavascriptv5.18.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mapkit
import * as mapkit from 'mapkit-typescript'
import mapkit from 'mapkit-typescript'
MapKit JS is loaded as a global script, not an npm module. This import provides types for the global 'mapkit' object.
Map
const map = new mapkit.Map('map-id', { center: new mapkit.CoordinateRegion(...) })
const map = new Map('map-id', ...) // Map not imported separately
Map class is a property of the global mapkit object. No separate import needed.
CoordinateRegion
const region: mapkit.CoordinateRegion = new mapkit.CoordinateRegion(...)
const region: CoordinateRegion = new mapkit.CoordinateRegion(...) // missing namespace
CoordinateRegion is a type/constructor under the mapkit namespace.
MarkerAnnotation
const annotation = new mapkit.MarkerAnnotation(...)
import { MarkerAnnotation } from 'mapkit-typescript'
MarkerAnnotation is not a named export; use mapkit.MarkerAnnotation.

Shows how to import and use mapkit-typescript to create a MapKit JS map with a centered region and hide the compass.

// Ensure MapKit JS script is loaded in HTML: <script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script> import * as mapkit from 'mapkit-typescript'; const map = new mapkit.Map('map', { center: new mapkit.CoordinateRegion( new mapkit.Coordinate(37.7749, -122.4194), new mapkit.CoordinateSpan(0.1, 0.1) ), }); map.showsCompass = mapkit.FeatureVisibility.Hidden;
Debug
Known issues
gotchaType definitions require proper typeRoots in tsconfig.json for TypeScript to find them.
fix
Add 'node_modules/mapkit-typescript' to typeRoots in tsconfig.json.
affects: all
gotchaImport mapkit as a namespace, not a default import. Default import will result in an empty object.
fix
Use 'import * as mapkit from 'mapkit-typescript''.
affects: all
gotchaMapKit JS must be loaded via script tag before using types; types do not include the runtime.
fix
Include <script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script> in your HTML.
affects: all
breakingVersion 5.x changes some API signatures compared to 4.x (e.g., Map constructor options).
fix
Update to match new signature or pin to older version.
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module 'mapkit-typescript' or its corresponding type declarations.
TypeScript is not configured to look in the mapkit-typescript folder.
fix
Add 'node_modules/mapkit-typescript' to the typeRoots array in tsconfig.json.
Property 'Map' does not exist on type 'typeof import("...")'.
Using default import instead of namespace import.
fix
Replace 'import mapkit from ...' with 'import * as mapkit from ...'.
TypeError: mapkit.Map is not a constructor.
MapKit JS runtime not loaded; types are present but MapKit JS script missing.
fix
Add the MapKit JS script tag to your HTML page before the TypeScript module runs.
Upgrade
Version history
5.18.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
32
OpenAI (training)
1
Resources
mapkit-typescript — npm install mapkit-typescript · libregistry