Giter Site home page Giter Site logo

angularjschile / angularjs-google-maps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from allenhwkim/angularjs-google-maps

0.0 2.0 0.0 18.79 MB

The Simplest AngularJS Google Maps V3 Directive

Home Page: http://ngmap.github.io

License: MIT License

JavaScript 94.06% CSS 5.36% Shell 0.57%

angularjs-google-maps's Introduction

GoogleMap AngularJS Directive

Build Status

NOTE: 1.1.0 is released.

  • marker directive can have icon attribute as JSON
  • map with init-event attribute for initialization by an event

NOTE: 1.0.0 is released.
Now, it covers all official google examples using new directives. The new directives are;

  • Layer Directives
    traffic-layer, transit-layer, weather-layer, bicycling-layer, cloud-layer, dynamic-maps-engine-layer, fusion-tables-layer, heatmap-layer, kml-layer, maps-engine-layer custom-control
  • info-window
  • map-data
  • map-type
  • overlay-map-type

Demo
Documentation

There is already one for this. However, I found myself doing totally different approach for this purpose than the existing one, such as;

  1. Everything in tag and attributes.
    Thus, basic users don't even have to know what Javascript is.
  2. Expose all original Google Maps V3 api to the user.
    No hiding, no wraping, or whatsoever. By doing so, programmers don't need to learn how to use this module. You only need to know Google Maps V3 API.

There is a blog that introduces this module. The title of it is 'Google Map As The Simplest Way'

To Get Started

For Bower users,

$ bower install ngmap

  1. Include ng-map.min.js as well as google maps.
    <script src="http://maps.google.com/maps/api/js"></script>
    <script src="http://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.min.js"></script>

  2. name angular app as ngMap, or add it as a dependency

    var myApp = angular.module('myApp', ['ngMap']);

After map is initialized, you will have one event and map instances

Event:

  • mapInitialized with parameter with map

    In case your map directive scope is different from your controller scope, use this event to get the map instance.

      app.controller('parentParentController', function($scope) {
        $scope.$on('mapInitialized', function(event, map) {
          map.setCenter( .... )
          ..
        });
      });
    

Instances:

  • $scope.map
  • $scope.map.markers
  • $scope.map.shapes
  • etc

Directives

<map .. >

As defined on MapOptions, you can add any attributes, and events starting witn on-. Please note that event value must be a function.

Example:

<map zoom="11" 
  center="[40.74, -74.18]" 
  disable-default-u-i="true"
  disable-double-click-zoom="true"
  draggable="false"
  draggable-cursor="help"
  dragging-cursor="move"
  keyboard-shortcuts="false"
  max-zoom="12"
  min-zoom="8"
  tilt="45"
  map-type-id="TERRAIN">
</map>

i.e. < zoom="11" center="[40.74, -74.18]"

<marker .. >

As defined on MarkerOptions, you can add any attributes, and events starting witn on-.

<map center="[40.74, -74.18]">
  <marker
      position="[40.76, -74.16]"
      title="Hello Marker"
      animation="Animation.BOUNCE"
      draggable="true"
      visible="true"
      icon="beachflag.png"></marker>
</map>

<shape .. >

Polyline, Circle, Polygon, Rectangle, and Images

 <map zoom="11" center="[40.74, -74.18]">
    <shape id="polyline" name="polyline" 
      geodesic="true" stroke-color="#FF0000" stroke-opacity="1.0" stroke-weight="2"
      path="[[40.74,-74.18],[40.64,-74.10],[40.54,-74.05],[40.44,-74]]" ></shape>
    <shape id="polygon" name="polygon" 
      stroke-color="#FF0000" stroke-opacity="1.0" stroke-weight="2"
      paths="[[40.74,-74.18],[40.64,-74.18],[40.84,-74.08],[40.74,-74.18]]" ></shape>
    <shape id="rectangle" name="rectangle" stroke-color='#FF0000' 
      stroke-opacity="0.8" stroke-weight="2"
      bounds="[[40.74,-74.18], [40.78,-74.14]]" editable="true" ></shape>
    <shape id="circle" name="circle" stroke-color='#FF0000'
      stroke-opacity="0.8"stroke-weight="2" 
      center="[40.70,-74.14]" radius="4000" editable="true" ></shape>
    <shape id="image" name="image" 
      url="https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg"
      bounds="[[40.71,-74.22],[40.77,-74.12]]" opacity="0.7" clickable="true" ></shape>
 </map>

<info-window .. >

Example:

<map center="-25.363882,131.044922" zoom="4">
  <info-window id="bar" position="-25.363882,131.044922" visible="true">
    <div ng-non-bindable>
      <div id="siteNotice"></div>
    </div>
  </info-window>
</map>

<custom-control .. >

Example:

  <map center="41.850033, -87.6500523" zoom="6">
    <custom-control id="home" position="TOP_RIGHT" index="1" on-click="click()">
      <div style="background-color: black; color:#fff;cursor:pointer">Home1</div>
    </custom-control>
  </map>

<map-data .. >

Example:

  <map zoom="4" center="-28, 137.883">
    <map-data 
      load-geo-json="https://storage.googleapis.com/maps-devrel/google.json"></map-data>
  </map>

Layer Directives

<bicycling-layer .. >

  <map zoom="14" center="42.3726399, -71.1096528">
    <bicycling-layer></bicycling-layer>
  </map>

<weather-layer .. > (deprecated) and <cloud-layer .. > (deprecated)

  <map zoom="6" center="49.265984,-123.127491">
    <weather-layer temperature-units="FAHRENHEIT"></weather-layer>
    <cloud-layer></cloud-layer>
  </map>

<fusion-tables-layer .. >

  <map zoom="11" center="41.850033, -87.6500523">
    <fusion-tables-layer query="{
      select: 'Geocodable address',
      from: '1mZ53Z70NsChnBMm-qEYmSDOvLXgrreLTkQUvvg'}">
    </fusion-tables-layer>
  </map>

<heatmap-layer .. >

  <map zoom="13" center="37.774546, -122.433523" map-type-id="SATELLITE">
    <heatmap-layer id="foo" data="taxiData"></heatmap>
  </map>

<maps-engine-layer .. >

  <map center="59.322506, 18.010025" zoom="14">
    <maps-engine-layer
      layer-id="06673056454046135537-08896501997766553811">
    </maps-engine-layer>
  </map>

<traffic-layer>

  <map zoom="13" center="34.04924594193164, -118.24104309082031">
    <traffic-layer></traffic-layer>
  </map>

<transit-layer>

  <map zoom="13" center="51.501904,-0.115871">
    <transit-layer></transit-layer>
  </map>

<dynamic-maps-engine-layer .. >

  <map center="59.322506, 18.010025" zoom="14">
    <dynamic-maps-engine-layer
      suppress-info-windows="true"
      clickable="true"
      on-mouseover="onMouseover()"
      on-mouseout="onMouseout()"
      layer-id="06673056454046135537-08896501997766553811">
    </dynamic-maps-engine-layer>
  </map>

<kml-layer .. >

  <map zoom="11" center="41.875696,-87.624207">
    <kml-layer url="http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml"></kml-layer>
  </map>

MapType Directives

<map-type .. >

  <map zoom="10" center="41.850033,-87.6500523"
    <map-type name="coordinate" object="CoordMapType">
    </map-type>
  </map>

<overlay-map-type .. >

  <map zoom="10" center="41.850033,-87.6500523">
    <overlay-map-type object="CoordMapType" index="0">
    </overlay-map-type>
  </map>

Advanced Examples

license

MIT License

angularjs-google-maps's People

Contributors

alexandrekilian avatar allenhwkim avatar csdigi avatar hamzaazeem avatar martinmicunda avatar

Watchers

 avatar  avatar

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.