Map and motion

Property map

Properties as price pins on a Google Map. Choose price pins or location icon pins. Pins drop in, click one to open a card, and pins that are close together group into a cluster.

Price pins

Default. Each pin shows the price. Pins drop in when the map scrolls into view, and the card pops in when you click a pin. Reload to see the drop again.

<div class="map-view" data-map-marker="price" ...> YOUR_API_KEY is not a real key, so the demo map is shown. With a real key the same markup shows Google Maps.

Location icon pins

A classic map pin with a home icon. Sale pins are green, rent pins are brass. Same data, same animations.

<div class="map-view" data-map-marker="icon" ...>

Setup

  1. Create a key in the Google Cloud Console and turn on Maps JavaScript API. Restrict the key to your website address.
  2. Put the key in data-map-key. If it is empty, or still YOUR_API_KEY, the demo map is shown.
  3. Add your properties as JSON and point data-property-map at it.
<div class="map-view" data-property-map="#map-data" data-map-key="API_KEY"></div>

<script type="application/json" id="map-data">
[
  { "id": 1, "lat": 40.730, "lng": -73.987, "price": "$550,000",
    "title": "Maple Court House", "address": "2726 Shinn Street, New York",
    "image": "assets/img/properties/family-house-garden.webp", "url": "property-details.html",
    "status": "sale", "beds": 4, "baths": 3, "area": "2,450 sq ft" }
]
</script>

<script src="assets/js/icons.min.js"></script>
<script src="assets/js/map-view.min.js"></script>

If Google rejects the key, the map falls back to the demo map by itself.

Full width

Use .map-view--full for a map that fills the screen below the header, for example on a map listing page.

Attributes and classes

NamePurpose
data-property-mapSelector of the JSON script that holds the properties.
data-map-keyGoogle Maps API key.
data-map-zoomStart zoom. By default the map fits all pins.
data-map-markerprice (default) or icon.
data-map-animatefalse turns off the pin drop and the card pop-in. Both are also off for visitors who prefer reduced motion.
data-map-centerlat,lng to start at a fixed place.
.map-viewThe map box (560px high; 480px on phones).
.map-view--fullFull screen height below the header.
.map-pin, .map-pin--icon, .is-rent, .is-activePin (price or icon). Rent pins are brass. Added by map-view.js.
.map-clusterGroup of close pins. Click to zoom in.
.map-popupProperty card that opens above a pin.

Keyboard: pins are buttons. Escape closes the card, then leaves full screen. Map colors are set in MAP_STYLE at the top of map-view.js.