01.
<div id=
"map"
></div>
02.
<script>
03.
04.
function
initMap() {
05.
var
mapOptions = {
06.
center: {lat: 13.847860, lng: 100.604274},
07.
zoom: 10,
08.
}
09.
10.
var
maps =
new
google.maps.Map(document.getElementById(
"map"
),mapOptions);
11.
12.
var
marker, info;
13.
14.
$.getJSON(
"json.php"
,
function
(jsonObj) {
15.
$.each(jsonObj,
function
(i, item){
16.
marker =
new
google.maps.Marker({
17.
position:
new
google.maps.LatLng(item.placeLat,item.placeLong),
18.
map: maps,
19.
20.
});
21.
22.
info =
new
google.maps.InfoWindow();
23.
24.
google.maps.event.addListener(marker,
'click'
, (
function
(marker, i) {
25.
return
function
() {
26.
info.setContent(item.placName);
27.
info.open(maps,marker);
28.
}
29.
})(marker, i));
30.
31.
});
32.
33.
});
34.
35.
}
36.
</script>