All Projects → yuanqing → Load Google Maps Api

yuanqing / Load Google Maps Api

Licence: mit
🌏 A lightweight Promise-returning helper for loading the Google Maps JavaScript API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Load Google Maps Api

react-google-static
🌍 A React wrapper for Google Static Maps API.
Stars: ✭ 37 (-77.71%)
Mutual labels:  google, google-maps, google-maps-api
Use Places Autocomplete
😎 📍 React hook for Google Maps Places Autocomplete.
Stars: ✭ 739 (+345.18%)
Mutual labels:  google-maps, google-maps-api
Leku
🌍 Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
Stars: ✭ 612 (+268.67%)
Mutual labels:  google, google-maps
Wanderlust The Travellers App
👟 An android application for travellers which allows them to save their journey experiences at one place in an organizable way. For detailed description, read the README.md file. Moreover, the application's design follows the latest HCI and UI/UX design guidelines.
Stars: ✭ 23 (-86.14%)
Mutual labels:  google-maps, google-maps-api
Firebase-Realtime-Car-Moving-On-JavaScript-Google-Maps
This is the solution for moving realtime cars on Google Maps JavaScript using Google Firebase Realtime Database.
Stars: ✭ 26 (-84.34%)
Mutual labels:  google-maps, google-maps-api
Flask Googlemaps
Easy way to add GoogleMaps to Flask applications. maintainer: @RiverFount
Stars: ✭ 550 (+231.33%)
Mutual labels:  google-maps, google-maps-api
Sketch Map Generator
Sketch plugin to fill a shape with a map generated from a given location using Google Maps and Mapbox
Stars: ✭ 824 (+396.39%)
Mutual labels:  google, google-maps
google-maps-services-php
PHP client library(SDK) for Google Maps API Web Services
Stars: ✭ 50 (-69.88%)
Mutual labels:  google-maps, google-maps-api
Maplace.js
A Google Maps Javascript plugin for jQuery.
Stars: ✭ 1,021 (+515.06%)
Mutual labels:  google-maps, google-maps-api
Magento2 Google Address Lookup
Provides an address lookup service on a Magento 2 store powered by the Google Places API
Stars: ✭ 46 (-72.29%)
Mutual labels:  google-maps, google-maps-api
Bikedeboa
A (Progressive) Web App to find, map and review bike parkings in the cities of Brazil.
Stars: ✭ 54 (-67.47%)
Mutual labels:  google-maps, google-maps-api
hopOn
A car rental flutter application using firebase and google maps API
Stars: ✭ 68 (-59.04%)
Mutual labels:  google-maps, google-maps-api
Placepicker
Free Android Map Place Picker alternative using Geocoder instead of Google APIs
Stars: ✭ 126 (-24.1%)
Mutual labels:  google, google-maps
Snazzy Info Window
Customizable info windows using the Google Maps JavaScript API.
Stars: ✭ 560 (+237.35%)
Mutual labels:  google-maps, google-maps-api
Google-Maps-API-with-PHP-MySQL
A Snippet of code to help you in Google Maps API. In this Script PHP Array and MySQL is used to store Latitude and Longitude. This script is made for those who needs a Map with Multiple Markers which changes it's Position Dynamically. In other words, This is made for people who need t a Map solution for Uber Like Application
Stars: ✭ 50 (-69.88%)
Mutual labels:  google-maps, google-maps-api
React Google Maps Api
React Google Maps API
Stars: ✭ 791 (+376.51%)
Mutual labels:  google-maps, google-maps-api
google-maps-statistics
Visualizing Geographic Statistical Data with Google Maps
Stars: ✭ 32 (-80.72%)
Mutual labels:  google-maps, google-maps-api
LocationAware
Set alarms for location in map
Stars: ✭ 34 (-79.52%)
Mutual labels:  google-maps, google-maps-api
React Native Maps Directions
Directions Component for `react-native-maps`
Stars: ✭ 846 (+409.64%)
Mutual labels:  google-maps, google-maps-api
Google Maps React
Companion code to the "How to Write a Google Maps React Component" Tutorial
Stars: ✭ 1,542 (+828.92%)
Mutual labels:  google, google-maps

load-google-maps-api npm Version Build Status Bundle Size

A lightweight Promise-returning helper for loading the Google Maps JavaScript API

  • The Promise’s fulfilled callback is passed the google.maps object
  • Optionally set a timeout, an API key, the language, and more

Usage

Editable demo (CodePen)

const loadGoogleMapsApi = require('load-google-maps-api')

loadGoogleMapsApi().then(function (googleMaps) {
  new googleMaps.Map(document.querySelector('.map'), {
    center: {
      lat: 40.7484405,
      lng: -73.9944191
    },
    zoom: 12
  })
}).catch(function (error) {
  console.error(error)
})

N.B. Just like the Google Maps API itself, this module is client-side only.

Motivation

Without this module, you would need to specify a named global callback, and pass said callback’s name as a parameter in the script tag’s src. For example:

<script>
window.googleMapsOnLoad = function () {
  // `window.google.maps` available here
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=googleMapsOnLoad"></script>

This module abstracts this ceremony away, and fits better with modern bundlers like Browserify or Webpack.

API

const loadGoogleMapsApi = require('load-google-maps-api')

loadGoogleMapsApi([options])

Returns a Promise.

  • Fulfilled if loading was successful. The fulfilled callback is passed the google.maps object. If loadGoogleMapsApi is called multiple times on a page, the fulfilled callback will be passed the previously-loaded google.maps object.
  • Rejected if we weren’t able to load the Google Maps API after options.timeout.

See Usage.

options is an optional object literal:

Key Description Default
apiUrl The Google Maps API script tag URL 'https://maps.googleapis.com/maps/api/js'
channel Client usage reporting channel undefined
client Client ID undefined
key Your API key undefined
language Language undefined
libraries Supplemental libraries to load []
region Region undefined
timeout Time in milliseconds before rejecting the Promise 10000
v API version undefined

Installation

$ yarn add load-google-maps-api

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].