โดย M030 » 02/12/2015 1:28 pm
Google map ไม่ search ตามสถานที่ที่ต้องการ
ตอนนี้เปลี่ยนมาใช้ api google map แบบ javascript ค่ะ เช่นเรา search ภูเก็ต มันยังขึ้น dm, อยุ่ค่ะ
code ***.php
โค้ด: เลือกทั้งหมด
$address = request_var('address', '', true);
$address = $subdistrict;
$province_add = $province;
$zipcodes_add = $zipcode;
$api = 'AIzaSyBuNORhP8fRDljXWbfvDKBN6D6UWVfxV14';
$add = $address.=$province.=$zipcode; // $address = เสนานิคม เราสามารถ Get หรือ ทำเป็นฟอร์มรับค่ามาก่อนได้
$latitude = 13.7246005;
$longitude = 100.6331108;
// $formatted_address = $resp['results'][0]['formatted_address'];
$this->template->assign_block_vars('m_map_subdistrict', array(
'LATITUDE' => $latitude,
'LONGITUDE' => $longitude,
'FORMATTED_ADDRESS' => $formatted_address,
'API_KEY'=> $api,
'ADDRESS'=>$add,
));
code ***.html
โค้ด: เลือกทั้งหมด
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng("{m_map_subdistrict.LATITUDE}", "{m_map_subdistrict.LONGITUDE}");
var mapOptions = {zoom : 8, center : myLatlng};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var contentString = '<div style="font-size: 18px;">{m_map_subdistrict.ADDRESS}</div>';
var infowindow = new google.maps.InfoWindow({
content : contentString
});
var marker = new google.maps.Marker({
position : myLatlng,
map : map,
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
- phuket.png (175.9 KiB) Viewed 1582 times
Google map ไม่ search ตามสถานที่ที่ต้องการ
ตอนนี้เปลี่ยนมาใช้ api google map แบบ javascript ค่ะ เช่นเรา search ภูเก็ต มันยังขึ้น dm, อยุ่ค่ะ
code ***.php
[code=php]
$address = request_var('address', '', true);
$address = $subdistrict;
$province_add = $province;
$zipcodes_add = $zipcode;
$api = 'AIzaSyBuNORhP8fRDljXWbfvDKBN6D6UWVfxV14';
$add = $address.=$province.=$zipcode; // $address = เสนานิคม เราสามารถ Get หรือ ทำเป็นฟอร์มรับค่ามาก่อนได้
$latitude = 13.7246005;
$longitude = 100.6331108;
// $formatted_address = $resp['results'][0]['formatted_address'];
$this->template->assign_block_vars('m_map_subdistrict', array(
'LATITUDE' => $latitude,
'LONGITUDE' => $longitude,
'FORMATTED_ADDRESS' => $formatted_address,
'API_KEY'=> $api,
'ADDRESS'=>$add,
));
[/code]
code ***.html
[code=php]
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
function initialize() {
var myLatlng = new google.maps.LatLng("{m_map_subdistrict.LATITUDE}", "{m_map_subdistrict.LONGITUDE}");
var mapOptions = {zoom : 8, center : myLatlng};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var contentString = '<div style="font-size: 18px;">{m_map_subdistrict.ADDRESS}</div>';
var infowindow = new google.maps.InfoWindow({
content : contentString
});
var marker = new google.maps.Marker({
position : myLatlng,
map : map,
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
[/code]
[attachment=0]phuket.png[/attachment]