@@ 69-105 (lines=37) @@ | ||
66 | } |
|
67 | } |
|
68 | ||
69 | public function useGoogleMap() |
|
70 | { |
|
71 | $this->script = <<<EOT |
|
72 | function initGoogleMap(name) { |
|
73 | var lat = $('#{$this->id['lat']}'); |
|
74 | var lng = $('#{$this->id['lng']}'); |
|
75 | ||
76 | var LatLng = new google.maps.LatLng(lat.val(), lng.val()); |
|
77 | ||
78 | var options = { |
|
79 | zoom: 13, |
|
80 | center: LatLng, |
|
81 | panControl: false, |
|
82 | zoomControl: true, |
|
83 | scaleControl: true, |
|
84 | mapTypeId: google.maps.MapTypeId.ROADMAP |
|
85 | } |
|
86 | ||
87 | var container = document.getElementById("map_"+name); |
|
88 | var map = new google.maps.Map(container, options); |
|
89 | ||
90 | var marker = new google.maps.Marker({ |
|
91 | position: LatLng, |
|
92 | map: map, |
|
93 | title: 'Drag Me!', |
|
94 | draggable: true |
|
95 | }); |
|
96 | ||
97 | google.maps.event.addListener(marker, 'dragend', function (event) { |
|
98 | lat.val(event.latLng.lat()); |
|
99 | lng.val(event.latLng.lng()); |
|
100 | }); |
|
101 | } |
|
102 | ||
103 | initGoogleMap('{$this->id['lat']}{$this->id['lng']}'); |
|
104 | EOT; |
|
105 | } |
|
106 | ||
107 | public function useTencentMap() |
|
108 | { |
|
@@ 107-152 (lines=46) @@ | ||
104 | EOT; |
|
105 | } |
|
106 | ||
107 | public function useTencentMap() |
|
108 | { |
|
109 | $this->script = <<<EOT |
|
110 | function initTencentMap(name) { |
|
111 | var lat = $('#{$this->id['lat']}'); |
|
112 | var lng = $('#{$this->id['lng']}'); |
|
113 | ||
114 | var center = new qq.maps.LatLng(lat.val(), lng.val()); |
|
115 | ||
116 | var container = document.getElementById("map_"+name); |
|
117 | var map = new qq.maps.Map(container, { |
|
118 | center: center, |
|
119 | zoom: 13 |
|
120 | }); |
|
121 | ||
122 | var marker = new qq.maps.Marker({ |
|
123 | position: center, |
|
124 | draggable: true, |
|
125 | map: map |
|
126 | }); |
|
127 | ||
128 | if( ! lat.val() || ! lng.val()) { |
|
129 | var citylocation = new qq.maps.CityService({ |
|
130 | complete : function(result){ |
|
131 | map.setCenter(result.detail.latLng); |
|
132 | marker.setPosition(result.detail.latLng); |
|
133 | } |
|
134 | }); |
|
135 | ||
136 | citylocation.searchLocalCity(); |
|
137 | } |
|
138 | ||
139 | qq.maps.event.addListener(map, 'click', function(event) { |
|
140 | marker.setPosition(event.latLng); |
|
141 | }); |
|
142 | ||
143 | qq.maps.event.addListener(marker, 'position_changed', function(event) { |
|
144 | var position = marker.getPosition(); |
|
145 | lat.val(position.getLat()); |
|
146 | lng.val(position.getLng()); |
|
147 | }); |
|
148 | } |
|
149 | ||
150 | initTencentMap('{$this->id['lat']}{$this->id['lng']}'); |
|
151 | EOT; |
|
152 | } |
|
153 | ||
154 | public function useYandexMap() |
|
155 | { |
|
@@ 154-186 (lines=33) @@ | ||
151 | EOT; |
|
152 | } |
|
153 | ||
154 | public function useYandexMap() |
|
155 | { |
|
156 | $this->script = <<<EOT |
|
157 | function initYandexMap(name) { |
|
158 | ymaps.ready(function(){ |
|
159 | ||
160 | var lat = $('#{$this->id['lat']}'); |
|
161 | var lng = $('#{$this->id['lng']}'); |
|
162 | ||
163 | var myMap = new ymaps.Map("map_"+name, { |
|
164 | center: [lat.val(), lng.val()], |
|
165 | zoom: 18 |
|
166 | }); |
|
167 | ||
168 | var myPlacemark = new ymaps.Placemark([lat.val(), lng.val()], { |
|
169 | }, { |
|
170 | preset: 'islands#redDotIcon', |
|
171 | draggable: true |
|
172 | }); |
|
173 | ||
174 | myPlacemark.events.add(['dragend'], function (e) { |
|
175 | lat.val(myPlacemark.geometry.getCoordinates()[0]); |
|
176 | lng.val(myPlacemark.geometry.getCoordinates()[1]); |
|
177 | }); |
|
178 | ||
179 | myMap.geoObjects.add(myPlacemark); |
|
180 | }); |
|
181 | ||
182 | } |
|
183 | ||
184 | initYandexMap('{$this->id['lat']}{$this->id['lng']}'); |
|
185 | EOT; |
|
186 | } |
|
187 | } |
|
188 |