สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network
Moderator: mindphp , ผู้ดูแลกระดาน
M030
PHP Super Hero Member
โพสต์: 532 ลงทะเบียนเมื่อ: 07/09/2015 10:06 am
โพสต์ที่ยังไม่ได้อ่าน
โดย 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
tsukasaz
PHP VIP Members
โพสต์: 22002 ลงทะเบียนเมื่อ: 18/04/2012 9:39 am
โพสต์ที่ยังไม่ได้อ่าน
โดย tsukasaz » 03/12/2015 2:12 pm
ตัวอย่างค้นหาตามชื่อสถานที่ครับ
โค้ด: เลือกทั้งหมด
<!DOCTYPE html>
<html>
<head>
<title>Place details</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://maps.googleapis.com/maps/api/js?callback=initMap" async defer></script>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {zoom: 15});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': 'บางพูด ปากเกร็ด นนทบุรี'}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
</body>
</html>
The last bug isn't fixed until the last user is dead. (Sidney Markowitz, 1995 )
M030
PHP Super Hero Member
โพสต์: 532 ลงทะเบียนเมื่อ: 07/09/2015 10:06 am
โพสต์ที่ยังไม่ได้อ่าน
โดย M030 » 04/12/2015 2:45 pm
ขอบคุณค่ะ
เดี๋ยวขอลองทำตามก่อนนะค่ะ
M030
PHP Super Hero Member
โพสต์: 532 ลงทะเบียนเมื่อ: 07/09/2015 10:06 am
โพสต์ที่ยังไม่ได้อ่าน
โดย M030 » 05/12/2015 1:33 pm
tsukasaz เขียน: ตัวอย่างค้นหาตามชื่อสถานที่ครับ
โค้ด: เลือกทั้งหมด
<!DOCTYPE html>
<html>
<head>
<title>Place details</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://maps.googleapis.com/maps/api/js?callback=initMap" async defer></script>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {zoom: 15});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': 'บางพูด ปากเกร็ด นนทบุรี'}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
</body>
</html>
ลองนำโค้ดมาใส่ดูแล้วค่ะ แต่ google map ยังไม่แสดงเลยค่ะ
โค้ด: เลือกทั้งหมด
<script
src="https://maps.googleapis.com/maps/api/js?callback=initialize" async defer></script>
<!-- BEGIN m_map_subdistrict -->
<script>
function initialize() {
var myLatlng = new google.maps.LatLng("{m_map_subdistrict.LATITUDE}", "{m_map_subdistrict.LONGITUDE}");
var mapOptions = {zoom : 5, center : myLatlng};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng( "{m_map_subdistrict.LATITUDE}" , "{m_map_subdistrict.LONGITUDE}")
});
var contentString = "{m_map_subdistrict.DISTRICT_ADD}";
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': 'บางพูด ปากเกร็ด นนทบุรี'}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
var infowindow = new google.maps.InfoWindow({
content : contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map-canvas" style="width:750px; height:500px; margin-left: 200px; margin-top:60px;"></div>
<!-- END m_map_subdistrict -->
M030
PHP Super Hero Member
โพสต์: 532 ลงทะเบียนเมื่อ: 07/09/2015 10:06 am
โพสต์ที่ยังไม่ได้อ่าน
โดย M030 » 05/12/2015 1:37 pm
ได้แล้วค่ะ ต้องแก้ที่จุด market ค่ะ ขอบคุณมากนะค่ะ
0 ตอบกลับ
1404 แสดง
โพสต์ล่าสุด โดย M034
21/05/2016 12:29 pm
0 ตอบกลับ
1219 แสดง
โพสต์ล่าสุด โดย jamepiyawat
13/08/2019 6:44 pm
0 ตอบกลับ
5549 แสดง
โพสต์ล่าสุด โดย buay
02/07/2014 2:17 pm
1 ตอบกลับ
1165 แสดง
โพสต์ล่าสุด โดย LEG
23/04/2020 8:51 am
0 ตอบกลับ
740 แสดง
โพสต์ล่าสุด โดย jamepiyawat
21/08/2019 6:43 pm
0 ตอบกลับ
1282 แสดง
โพสต์ล่าสุด โดย kanjanakam
11/03/2021 5:05 pm
0 ตอบกลับ
837 แสดง
โพสต์ล่าสุด โดย jamepiyawat
10/08/2019 6:33 pm
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 133