MapQuest.com
Business
Navigation
Getting Started
Developer Blog
Web SDKs
MapQuest.js
API Reference
Examples
Maps
Map with MapQuest Control
Map with Custom Tiles
Map with Layers Control
Map with Leaflet Draw Control
Geocoding
Basic Geocoding
Geocoding with a Single Line Address
Geocoding with an Advanced Location Object
Geocoding with Multiple Locations
Reverse Geocoding
Geocoding with Custom Icons
Geocoding with Custom Popups
Directions
Basic Directions
Directions with an Advanced Location Object
Directions with Multiple Waypoints
Directions with Optimized Waypoints
Directions with Alternate Routes
Directions with Custom Icons and Ribbons
Directions with Disabled Dragging
Directions with Disabled Traffic Ribbon
Directions that Avoid Toll Roads
Directions that Avoid Bridges and Tunnels
Biking Directions
Walking Directions
Map with a Directions Control
Map with a Directions Narrative Control
Search Ahead
Geocoding Control with Search Ahead
Filtering Results for Search Ahead
Traffic
Map with Traffic Layers
Map with Traffic Control
Miscellaneous
Adding Markers, Circles, and Polygons
Adding a GeoJSON layer
Adding a Tile Overlay
Adding an Image Overlay
Showing Marker Clusters
Showing Clusters as a Heat Map
PlaceSearch.js
APIs
Data Manager API
Directions API
Geocoding API
Icons API
Search API
Place Search API
Search Ahead API
Static Map API
Traffic API
Legacy Products
Leaflet Plugins
Tools
Lat/Lng Finder
Link to MapQuest
Share
Getting Started
Developer Blog
Documentation
Web SDKs
MapQuest.js
API Reference
Examples
Maps
Map with MapQuest Control
Map with Custom Tiles
Map with Layers Control
Map with Leaflet Draw Control
Geocoding
Basic Geocoding
Geocoding with a Single Line Address
Geocoding with an Advanced Location Object
Geocoding with Multiple Locations
Reverse Geocoding
Geocoding with Custom Icons
Geocoding with Custom Popups
Directions
Basic Directions
Directions with an Advanced Location Object
Directions with Multiple Waypoints
Directions with Optimized Waypoints
Directions with Alternate Routes
Directions with Custom Icons and Ribbons
Directions with Disabled Dragging
Directions with Disabled Traffic Ribbon
Directions that Avoid Toll Roads
Directions that Avoid Bridges and Tunnels
Biking Directions
Walking Directions
Map with a Directions Control
Map with a Directions Narrative Control
Search Ahead
Geocoding Control with Search Ahead
Filtering Results for Search Ahead
Traffic
Map with Traffic Layers
Map with Traffic Control
Miscellaneous
Adding Markers, Circles, and Polygons
Adding a GeoJSON layer
Adding a Tile Overlay
Adding an Image Overlay
Showing Marker Clusters
Showing Clusters as a Heat Map
PlaceSearch.js
new
APIs
Data Manager API
Directions API
Geocoding API
Icons API
Search API
Place Search API
Search Ahead API
Static Map API
Traffic API
Legacy Products
Leaflet Plugins
Tools
Lat/Lng Finder
Link to MapQuest
Share
You are viewing an older version of MapQuest.js. Check out
the latest version
.
MapQuest.js
Geocoding with a Single Line Address
Edit the code below and click "Try It Now" to display the result.
<html> <head> <script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script> <link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css"/> <script type="text/javascript"> window.onload = function() { L.mapquest.key = '8nIoYUx9GyjZsdehJySzjprSvZIqgM42'; L.mapquest.geocoding().geocode('Boston, MA', createMap); function createMap(error, response) { var location = response.results[0].locations[0]; var latLng = location.displayLatLng; var map = L.mapquest.map('map', { center: latLng, layers: L.mapquest.tileLayer('map'), zoom: 14 }); } } </script> </head> <body style="border: 0; margin: 0;"> <div id="map" style="width: 100%; height: 530px;"></div> </body> </html>
Try It Now