-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapview.php
69 lines (58 loc) · 2.07 KB
/
mapview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php require_once("function.php"); ?>
<?php
$json = file_get_contents('https://api.thingspeak.com/channels/409679/feeds.json?results=2');
$obj = json_decode($json);
$lati = end($obj->feeds)->field1;
$longti = end($obj->feeds)->field2;
$latitude = "23.7801569";
$longtitude = "90.4071984";
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script
src="https://maps.googleapis.com/maps/api/js?key=KEY">
</script>
</head>
<body>
<div id="googleMap" style="width:70%;height:500px; margin:1em 0em 1em 0em; padding-left:15%; text-align:center"></div>
<div class="mypanel"></div>
<script>
var address = "66, mohakhali; dhaka;";
$.getJSON("https://maps.googleapis.com/maps/api/geocode/json?address="+address+"&key=AIzaSyAYRKN2Ws4VtVfD6V5HYiddvlcxsv8CODM", function(data) {
var text = data.results[0].geometry.location.lat + "<br>";
var text2 = data.results[0].geometry.location.lng;
var res = text + " " + text2;
$(".mypanel").html(res);
});
</script>
<script>
var lati = "<?php echo $latitude; ?>";
var longval = "<?php echo $longtitude; ?>";
var truck = "truck10";
var myCenter=new google.maps.LatLng(lati,longval);
function initialize() {
var mapProp = {
center:myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.RoadMap
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker_build_1=new google.maps.Marker({
position:new google.maps.LatLng(lati,longval)
});
marker_build_1.setMap(map);
var infowindow1 = new google.maps.InfoWindow({
content: truck
});
google.maps.event.addListener(marker_build_1, 'click', function() {
infowindow1.open(map,marker_build_1);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>