Icons API
Icon Types
We have a variety of icon types including markers, circles, vias, and flags that can be used in both our Static Map API or our MapQuest Plugins for Leaflet.
Icon Sizes
Icon scale can be controlled. The icon service returns both standard and retina versions of icons. If the request contains "@2x" then the Icons API returns twice as many pixels for the given icon.
Standard Resolution URL
Retina Resolution URL
With retina resolution icons, you need to define the height and width of the icons to downscale them to the correct dimensions on retina screens. Below are tables with the various icon dimensions.
Marker Sizes
marker, marker-sm | marker-md | marker-lg | |
---|---|---|---|
Dimensions (in pixels) | height: 35, width: 28 | height: 44, width: 35 | height: 53, width: 42 |
Circle Sizes
circle, circle-sm | circle-md | circle-lg | |
---|---|---|---|
Dimensions (in pixels) | height: 28, width: 28 | height: 35, width: 35 | height: 42, width: 42 |
Via Sizes
via, via-sm | via-md | via-lg | |
---|---|---|---|
Dimensions (in pixels) | height: 10, width: 10 | height: 14, width: 14 | height: 18, width: 18 |
Flag Sizes
flag, flag-sm | flag-md | flag-lg | |
---|---|---|---|
Dimensions (in pixels) | height: 30, width: 60 | height: 35, width: 70 | height: 40, width: 80 |
Incident and Construction Sizes
incident, incident-sm, construction, construction-sm | incident-md, construction-md | incident-lg, construction-lg | |
---|---|---|---|
Dimensions (in pixels) | height: 25, width: 28 | height: 31, width: 35 | height: 33, width: 42 |
Icon Customization
Icons can be customized to include text, different colors, and have different sizes. Below is a table with the various icon types and customization you can do.
Markers
Key | Value | Example |
---|---|---|
marker | Default | |
marker-white | Default | |
marker-start | Default | |
marker-end | Default | |
marker-{size} | "sm" "md" "lg" Example: "marker-md" | |
marker-{symbol} | Any letter (letters will be capitalized) or integer from 0-999 Ex: "marker-A" | |
marker-{color} | Any hex value Ex: "marker-7B0099" | |
marker-{color1}-{color2} | Any two hex values Ex: "marker-F8E71C-417505" | |
marker-{size}-{color1}-{color2}-{symbol} marker-{size}-{color}-{symbol} | Any combination of various custom attributes. Ex: "marker-md-F8E71C-417505-A" Ex. "marker-lg-7B0099-42 |
Circles
Key | Value | Example |
---|---|---|
circle | Default | |
circle-white | Default | |
circle-start | Default | |
circle-end | Default | |
circle-{size} | "sm" "md" "lg" Example: "circle-md" | |
circle-{symbol} | Any letter (letters will be uppercase) or integer from 0-999 Ex: "circle-A" or "circle-100" | |
circle-{color} | Any hex value Ex: "circle-7B0099" | |
circle-{color1}-{color2} | Any two hex values Ex: "circle-F8E71C-417505" | |
circle-{size}-{color1}-{color2}-{symbol} | Any combination of various custom attributes. Either one or two hex values, a size (sm, md, lg), a letter or integer between 0-999 Ex: "circle-md-F8E71C-417505-A" Ex. Example: "circle-lg-7B0099-42" |
Vias
Key | Value | Example |
---|---|---|
via | Default | |
via-{size} | "sm" "md" "lg" Example: "via-md" | |
via-{color} | Any hex value Ex: "via-7B0099" | |
via-{color1}-{color2} | Any two hex values Ex: "via-3B5998-22407F" |
Flags
Key | Value | Example |
---|---|---|
flag | Default | |
flag-start | Default | |
flag-end | Default | |
flag-{size} | "sm" "md" "lg" Ex: "flag-hello-sm" Ex: "flag-hello-md" Ex: "flag-lg-hello" | |
flag-{color} | Any hex value Ex: "flag-7B0099" | |
flag-{color1}-{color2} | Any two hex values Ex: "flag-3B5998-22407F" | |
flag-{symbols} | Up to five letters, numbers, and characters except for "-" and "." (Characters will need to be URL escaped) (Letters will be capitalized) Ex: "flag-1"" Ex: "flag-$99" Ex: "flag-75%25" Ex: "flag-Hello" | |
flag-{size}-{color1}-{color2}-{symbol} flag-{size}-{color}-{symbol} | Any combination of various custom attributes. Either one or two hex values, a size (sm, md, lg), a letter or integer between 0-999 Ex: "flag-md-3B5998-22407F-food" Ex. "flag-lg-7B0099-drink" |
Incident
Key | Value | Example |
---|---|---|
incident-{size} | "sm" "md" "lg" Ex: "incidient-sm" Ex: "incident-md" Ex: "incident-lg" | |
incident-{severity} | "low" "medium" "high" Ex: "incident-low" Ex: "incident-medium" Ex: "incident-high" | |
incident-{severity}-{size} | Any combination of severity and size Ex: "incident-low-md" Ex: "incident-medium-lg" Ex: "incident-high-sm" |
Construction
Key | Value | Example |
---|---|---|
construction-{size} | "sm" "md" "lg" Ex: "construction-sm" Ex: "construction-md" Ex: "construction-lg" | |
construction-{severity} | "low" "medium" "high" Ex: "construction-low" Ex: "construction-medium" Ex: "construction-high" | |
construction-{severity}-{size} | Any combination of various custom attributes. Ex: "construction-low-md" Ex: "construction-low-md" Ex: "construction-low-md" |
External Icons
In addition to our own icon set, you can reference your custom icons in png, jpg, and gif format. This is specifically for use in our Static Map v5 API, but it is also caches your image for improved responsiveness. In the example below, we will self reference but only because it makes examples easy.
https://assets.mapquestapi.com/icon/v2/external/https://assets.mapquestapi.com/icon/v2/marker@2x.png
If you want to flush a cached icon, attach ?flush=true
as a query parameter.
Use Icons with Leaflet
Below is sample code on how to use our basic marker with our MapQuest Plugins for Leaflet.
var markerSize = {'sm': [28, 35], 'md': [35, 44], 'lg': [42, 53]};
var markerAnchor = {'sm': [14, 35], 'md': [17, 44], 'lg': [21, 53]};
var markerPopupAnchor = {'sm': [1, -35], 'md': [1, -44], 'lg': [2, -53]};
var smallMarker = L.icon({
iconUrl: 'https://assets.mapquestapi.com/icon/v2/marker-sm.png',
iconRetinaUrl: 'https://assets.mapquestapi.com/icon/v2/marker-sm@2x.png',
iconSize: markerSize.sm,
iconAnchor: markerAnchor.sm,
popupAnchor: markerPopupAnchor.sm
});
var mediumMarker = L.icon({
iconUrl: 'https://assets.mapquestapi.com/icon/v2/marker-md.png',
iconRetinaUrl: 'https://assets.mapquestapi.com/icon/v2/marker-md@2x.png',
iconSize: markerSize.md,
iconAnchor: markerAnchor.md,
popupAnchor: markerPopupAnchor.md
});
var largeMarker = L.icon({
iconUrl: 'https://assets.mapquestapi.com/icon/v2/marker-lg.png',
iconRetinaUrl: 'https://assets.mapquestapi.com/icon/v2/marker-lg@2x.png',
iconSize: markerSize.lg,
iconAnchor: markerAnchor.lg,
popupAnchor: markerPopupAnchor.lg
});