rails-marker 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec6ae65ce3f7aec3a36cc96793768d17dc5e74cb
4
- data.tar.gz: bb269d5807c2caf2c18526a963fdb75c2c804321
3
+ metadata.gz: 3e0c54c1c84764a7c41646f361b7620c9fd51c66
4
+ data.tar.gz: 4a6cf18c690da10eb036c0e13444d10785442afd
5
5
  SHA512:
6
- metadata.gz: c08631be597aa235db3558b0cc401e48a2ca0672296805f74261cc1e5f500ef6be38df2a80be95608a8546994f4d951a4a7fe7024af55e3d115618ca8c990f90
7
- data.tar.gz: fc5e6b1a7ed6888011d10517c5dbe9d6cae80a735e7dd8ba17418bb42eaedfc70204224d13c7cefb76d6a3b36d85dafa8964134ea27a80944e7d417426abe344
6
+ metadata.gz: 0ea604676df574406db1270830efc907ece9f3ffd228d91883b4f8f77cbc4100f976ed4edd4cb64461ac043a7ae1c114c929d439735dff02ea18c00bcd45966b
7
+ data.tar.gz: 3c06410f03ff1afdb827e27893f170e8c2da339d640a115dcbe4b84c79378ee4a8c4256b3a961b6729fddf4fbcdcd8bc0584b79fca1bef76c04a61b680d7df50
@@ -1,4 +1,4 @@
1
- Copyright 2012 Aimbulance http://www.aimbulance.com/
1
+ Copyright 2017 Fodojo LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -58,7 +58,10 @@ And you want edit fields zoom, longitude and latitude:
58
58
  <%= form_for @office do |f| %>
59
59
  <%= f.text_field :longitude, data: { map: 'lng' } %>
60
60
  <%= f.text_field :latitude, data: { map: 'lat' } %>
61
+
62
+ // Optional fields
61
63
  <%= f.text_field :zoom, data: { map: 'zoom' } %>
64
+ <%= f.text_field :radius, data: { map: 'radius' } %>
62
65
 
63
66
  <%= f.marker_field :map %>
64
67
  <% end %>
@@ -76,4 +79,4 @@ It's all you need! Just move the marker, and zoom, latitude and longitude fields
76
79
  4. Push to the branch (`git push origin my-new-feature`)
77
80
  5. Create new Pull Request
78
81
 
79
- Copyright (c) 2017 Fodojo, released under the MIT license
82
+ Copyright (c) 2017 Fodojo LLC, released under the MIT license
@@ -3,5 +3,6 @@ initMarkerMap = () ->
3
3
 
4
4
  elements.forEach (el, index, array) ->
5
5
  map = new MapGoogle(el)
6
+ $(el).data('map', map)
6
7
 
7
8
  window['initMarkerMap'] = initMarkerMap
@@ -6,6 +6,7 @@ class MapGoogle
6
6
  lat: 50.44067063154785
7
7
  lng: 30.52654266357422
8
8
  zoom: 6
9
+ radius: 1000
9
10
 
10
11
  @element = $(@dom)
11
12
  @options = $.extend defaults, @element.data(), options
@@ -15,6 +16,7 @@ class MapGoogle
15
16
  @options.field_lat = "[data-#{@name}='lat']"
16
17
  @options.field_lng = "[data-#{@name}='lng']"
17
18
  @options.field_zoom = "[data-#{@name}='zoom']"
19
+ @options.field_radius = "[data-#{@name}='radius']"
18
20
 
19
21
  this._setup()
20
22
 
@@ -26,6 +28,7 @@ class MapGoogle
26
28
  @field_lat = $(@options.field_lat + ':eq(0)')
27
29
  @field_lng = $(@options.field_lng + ':eq(0)')
28
30
  @field_zoom = $(@options.field_zoom + ':eq(0)')
31
+ @field_radius = $(@options.field_radius + ':eq(0)')
29
32
 
30
33
  google.maps.event.addListener(@marker, 'dragend', (event) =>
31
34
  pos = @marker.getPosition()
@@ -40,6 +43,11 @@ class MapGoogle
40
43
  @field_zoom.val @map.getZoom()
41
44
  )
42
45
 
46
+ if @field_radius.length > 0
47
+ number = this._parse_value(@field_radius, @options.radius)
48
+ @circle = this._build_circle(radius: number)
49
+ @circle.bindTo('center', @marker, 'position')
50
+
43
51
  placeMarker: (location) ->
44
52
  marker = this._build_marker {position: location}
45
53
 
@@ -75,6 +83,20 @@ class MapGoogle
75
83
 
76
84
  new google.maps.Marker(settings)
77
85
 
86
+ _build_circle: (options = {}) ->
87
+ defaults =
88
+ map: @map
89
+ strokeColor: '#FF0000',
90
+ strokeOpacity: 0.8,
91
+ strokeWeight: 2,
92
+ fillColor: '#FF0000',
93
+ fillOpacity: 0.35,
94
+ radius: 1000 # 1 kilometr
95
+
96
+ settings = $.extend defaults, options
97
+
98
+ new google.maps.Circle(settings)
99
+
78
100
  _parse_value: (field, default_value) ->
79
101
  value = parseFloat $(field).val()
80
102
 
@@ -1,3 +1,3 @@
1
1
  module Marker
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-marker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Galeta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-13 00:00:00.000000000 Z
12
+ date: 2017-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -49,7 +49,8 @@ files:
49
49
  - lib/marker/version.rb
50
50
  - lib/rails_marker.rb
51
51
  homepage: https://github.com/galetahub/rails-marker
52
- licenses: []
52
+ licenses:
53
+ - MIT
53
54
  metadata: {}
54
55
  post_install_message:
55
56
  rdoc_options: []