Giter Site home page Giter Site logo

ngmapdirect's Introduction

Angularjs Map & Directions

Angularjs Google Maps & Directions Directive

This is used when you need a map and/or direction in one area.

For independant map & directions take a look at the twin repo at npmapdirectindie

Required Dependencies for Component:

  • Angularjs

    Stable: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>

    --or--

    Unstable: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>

    Please refer to the following url for version(stability) discrepancies.

    You can still use the "unstable" version for the latest animate and other ng directives.

  • Google Maps Api v3

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

Optional Dependencies:

  • Zurb Foundation

    Used in simple styling of map and directions.

    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.1.6/css/foundation.min.css" />

Usage

Below illustrates a simple setup:

<!DOCTYPE html>
<html ng-app="mapComponent">
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/4.1.6/css/foundation.min.css" />
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
	<map></map>
</body>

</html>

Adding ng-app="mapComponent" to the <html> tag implies the module mapComponent is the root module for the app.

If you do not want this side effect, you can wrap the <map></map> element with a div tag like so:

<div ng-app="mapComponent">
	<map></map>
</div>

leaving the <html> tag clear of attributes as you would per normal situation.

IE browser and validation note

If you care about IE versions <= 9 use the attribute or class version of <map></map> directive.

The results would be like so respectively:

<div data-map></div>

or

<div class="map"></div>

The width and height of the map are controlled explicitly by CSS.

Edits should be made to the CSS and not via javascript.

Options:

The following options are available as attributes for map/directions customization:

Denotes defaults

  • destination: address to user will arrive to. 1600 Amphitheatre Parkway, Santa Clara County, CA
  • markerContent: content of the initial marker and if not using directions. Google HQ
  • zoom: zoom level of the initial map. 15
  • type: types of map roadmap, satellite, hybird, & terrain. roadmap
  • directions: a boolean to show or hide directions. true

Ex:

<map destination="Philadelphia PA" type="hybrid" zoom="18" marker-content="Philly"></map>

as previously noted the below version would be valid (validators):

<div class="map" data-destination="Philadelphia PA" data-type="hybrid" data-zoom="18" data-marker-content="Philly"></div>

The above would result into a destination of Philadelphia PA with the map type of hybrid so both roadmap & satellite combined.

Along with an initial zoom level of 18 and if a user were to click on the marker the info window would appear to display Philly.

Any options omitted will simply default to the data described above.

Todo

  • Add more options.
  • Maybe create a service as directive feeder.

ngmapdirect's People

Contributors

davidchase avatar

Watchers

 avatar  avatar

Forkers

kirill23

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.