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