Git Product home page Git Product logo

meteor-autoform-map's Introduction

Autoform map

Edit location coordinates with autoForm.

Setup

  1. Install meteor add yogiben:autoform-map

  2. Define your schema and set the autoform property like in the example below

Schemas = {}

@Cities = new Meteor.Collection('cities');

Schemas.Cities = new SimpleSchema
	name:
		type:String
		max: 60
		
	location:
		type: String
		autoform:
			type: 'map'
			afFieldInput:
      				geolocation: true
      				searchBox: true
      				autolocate: true

Cities.attachSchema(Schemas.Cities)
  1. Generate the form with {{> quickform}} or {{#autoform}}

e.g.

{{> quickForm collection="Cities" type="insert"}}

or

{{#autoForm collection="Cities" type="insert"}}
    {{> afQuickField name="name"}}
    {{> afQuickField name="location"}}
    <button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}

Coordinates will be saved as string in format latititude,longitude. Alternatively it can be an object. See schema below:

Schemas.Cities = new SimpleSchema
	location:
		type: Object
		autoform:
			type: 'map'
			afFieldInput:
				# options
	'location.lat':
		type: String
	'location.lng':
		type: String

Or if you want to save lat and lng as a number:

Schemas.Cities = new SimpleSchema
	location:
		type: Object
		autoform:
			type: 'map'
			afFieldInput:
				# options
	'location.lat':
		type: Number
		decimal: true
	'location.lng':
		type: Number
		decimal: true

Or if you want to save lat and lng as a array, important for GEOJson:

Schemas.Cities = new SimpleSchema
	location:
		type: [Number]
		decimal: true
		autoform:
			type: 'map'
			afFieldInput:
				# options

Options

mapType type of google map. Possible values: 'roadmap' 'satellite' 'hybrid' 'terrain'

width height valid css values for width and height attributes of map. Default width is set to '100%' and height is '200px'

defaultLat default latitude defaultLng default longitude

geolocation enables or disables geolocation feature. Defaults to false

searchBox enables or disables search box. Defaults to false

zoom zoom of the map. Defaults to 13

autolocate if set to true will automatically ask for user's location. Defaults to false

googleMap google maps specific options.

rendered function called when map is rendered. google.maps.Map will be passed as an argument.

reverse if set to true lat.lng will be reversed to lng.lat. Works only with strings.

	location:
		type: String
		autoform:
			afFieldInput:
				type: 'map'
				mapType: 'terrain'
				zoom: 8
				geolocation: true

meteor-autoform-map's People

Contributors

mpowaga avatar yogiben avatar hazemkhaled avatar rapito avatar vicnala avatar elie222 avatar filipenevola avatar fknipp avatar renancouto avatar

Watchers

James Cloos 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.