| @@ 53-89 (lines=37) @@ | ||
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | public function useGoogleMap() |
|
| 54 | { |
|
| 55 | $this->script = <<<EOT |
|
| 56 | (function() { |
|
| 57 | function initGoogleMap(name) { |
|
| 58 | var lat = $('#{$this->id['lat']}'); |
|
| 59 | var lng = $('#{$this->id['lng']}'); |
|
| 60 | ||
| 61 | var LatLng = new google.maps.LatLng(lat.val(), lng.val()); |
|
| 62 | ||
| 63 | var options = { |
|
| 64 | zoom: 13, |
|
| 65 | center: LatLng, |
|
| 66 | panControl: false, |
|
| 67 | zoomControl: true, |
|
| 68 | scaleControl: true, |
|
| 69 | mapTypeId: google.maps.MapTypeId.ROADMAP |
|
| 70 | } |
|
| 71 | ||
| 72 | var container = document.getElementById("map_"+name); |
|
| 73 | var map = new google.maps.Map(container, options); |
|
| 74 | ||
| 75 | var marker = new google.maps.Marker({ |
|
| 76 | position: LatLng, |
|
| 77 | map: map, |
|
| 78 | title: 'Drag Me!', |
|
| 79 | draggable: true |
|
| 80 | }); |
|
| 81 | ||
| 82 | google.maps.event.addListener(marker, 'dragend', function (event) { |
|
| 83 | lat.val(event.latLng.lat()); |
|
| 84 | lng.val(event.latLng.lng()); |
|
| 85 | }); |
|
| 86 | } |
|
| 87 | ||
| 88 | initGoogleMap('{$this->id['lat']}{$this->id['lng']}'); |
|
| 89 | })(); |
|
| 90 | EOT; |
|
| 91 | } |
|
| 92 | ||
| @@ 93-138 (lines=46) @@ | ||
| 90 | EOT; |
|
| 91 | } |
|
| 92 | ||
| 93 | public function useTencentMap() |
|
| 94 | { |
|
| 95 | $this->script = <<<EOT |
|
| 96 | (function() { |
|
| 97 | function initTencentMap(name) { |
|
| 98 | var lat = $('#{$this->id['lat']}'); |
|
| 99 | var lng = $('#{$this->id['lng']}'); |
|
| 100 | ||
| 101 | var center = new qq.maps.LatLng(lat.val(), lng.val()); |
|
| 102 | ||
| 103 | var container = document.getElementById("map_"+name); |
|
| 104 | var map = new qq.maps.Map(container, { |
|
| 105 | center: center, |
|
| 106 | zoom: 13 |
|
| 107 | }); |
|
| 108 | ||
| 109 | var marker = new qq.maps.Marker({ |
|
| 110 | position: center, |
|
| 111 | draggable: true, |
|
| 112 | map: map |
|
| 113 | }); |
|
| 114 | ||
| 115 | if( ! lat.val() || ! lng.val()) { |
|
| 116 | var citylocation = new qq.maps.CityService({ |
|
| 117 | complete : function(result){ |
|
| 118 | map.setCenter(result.detail.latLng); |
|
| 119 | marker.setPosition(result.detail.latLng); |
|
| 120 | } |
|
| 121 | }); |
|
| 122 | ||
| 123 | citylocation.searchLocalCity(); |
|
| 124 | } |
|
| 125 | ||
| 126 | qq.maps.event.addListener(map, 'click', function(event) { |
|
| 127 | marker.setPosition(event.latLng); |
|
| 128 | }); |
|
| 129 | ||
| 130 | qq.maps.event.addListener(marker, 'position_changed', function(event) { |
|
| 131 | var position = marker.getPosition(); |
|
| 132 | lat.val(position.getLat()); |
|
| 133 | lng.val(position.getLng()); |
|
| 134 | }); |
|
| 135 | } |
|
| 136 | ||
| 137 | initTencentMap('{$this->id['lat']}{$this->id['lng']}'); |
|
| 138 | })(); |
|
| 139 | EOT; |
|
| 140 | } |
|
| 141 | } |
|