Code Monkey home page Code Monkey logo

aurelia-google-maps's Introduction

aurelia-google-maps

Join the chat at https://gitter.im/Vheissu/aurelia-google-maps A highly configurable custom element for use in your Aurelia applications for inserting Google Maps into your application.

To Install

jspm install npm:aurelia-google-maps

Configuring For Use

Inside of your main.js/main.ts file simply load the plugin inside of the configure method using .plugin()

export function configure(aurelia) {
    aurelia.use
        .plugin('aurelia-google-maps', config => {
            config.options({
                apiKey: 'myapiKey'
            });
        })
}

Using It

Now you have Google Maps configure, to use it simply use the custom element <google-map></google-map> in your views.

Latitude/Longitude

Provide standard latitude and longitude values.

<template>
    <google-map latitude="37.323" longitude="-122.0527"></google-map>
</template>

Address

Provide a string as an address which then gets geocoded and the map is centred on this particular address.

<template>
    <google-map address="1600 Amphitheatre Parkway. Mountain View, CA 94043"></google-map>    
</template>

Zooming A Map

Taking the first example, lets add a zoom attribute and supply a value of 15. By default this is 8 if you do not supply a zoom value.

<template>
    <google-map latitude="37.323" longitude="-122.0527" zoom="15"></google-map>
</template>

These properties also support working with Aurelia's databinding, so you can bind any of the above to variables in your viewmodel and the map updates when these values are changed.

Map Click Event

It is possible to catch the map click events as specified by the Google Maps documentation. The map click event is added as a CustomEvent to the <google-map> DOM element with the event data added to the detail key. Example:

<google-map map-click.delegate="myEventHandler($event)"></google-map>
myEventHandler(event) {
    var latLng = event.detail.latLng,
        lat = latLng.lat(),
        lng = latLng.lng();
}

Supported Properties

  • latitude: A latitude value for the map
  • longitude: A longitude value for the map
  • address: Provide an address that gets geocoded into latitude and longitude coordinates
  • zoom: A zoom value, default is 8
  • disableDefaultUI: A boolean of true or false. Default is false.

Supported Events

  • map-click: Delegate a handler with map-click.delegate="callback($event)"

Todo

This element still is missing some features, but they are in development.

  • Expand upon markers ability to allow markers supplied by plugin to add themselves
  • Add in more configuration options
  • Work on making the custom element easier to extend
  • Work on supporting click events and events inside of the map, with callbacks support

aurelia-google-maps's People

Contributors

gitter-badger avatar vheissu avatar

Watchers

 avatar  avatar

Forkers

justindra

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.