function addMarker(json) { var same = null; $.each(markers, function(idx, val) { if (val == null) return true; if (val.data.coordinate_lat == json.coordinate_lat && val.data.coordinate_long == json.coordinate_long) { same = val.infoWindow; return false; } }); if (same) { same.content += '
'; same.content += '' + json.name + '
'; if (json.address_post) same.content += '〒' + json.address_post + '
'; same.content += json.address_address; if (json.address_landmark) same.content += '
' + json.address_landmark; same.content += '
'; return null; } else { var icon = ''; if (parseInt(json.terms_atm)) { icon = '/branch/inc/images/ico_atm.png'; } else { icon = '/branch/inc/images/ico_bank.png'; } var content = '
'; content += '' + json.name + '
'; if (json.address_post) content += '〒' + json.address_post + '
'; content += json.address_address; if (json.address_landmark) content += '
' + json.address_landmark; content += '
'; var params = { position: new google.maps.LatLng(json.coordinate_lat, json.coordinate_long), map: map, title: json.name, clickable: true, visible : true, icon: icon }; var marker = new google.maps.Marker(params); var infoWindow = new google.maps.InfoWindow({content : content}); google.maps.event.addListener(marker, 'click', function() { if (currentInfoWindow) { currentInfoWindow.close(); } if (currentInfoWindow != infoWindow) { infoWindow.open(map, marker); currentInfoWindow = infoWindow; } else { currentInfoWindow = null; } map.panTo(marker.position); }); return {id:json.id , marker:marker, infoWindow:infoWindow, data:json}; } } function setLatlngAverage(arr) { // var retvals = [34.278663, 131.631387, 8]; var _max_lat = null; var _min_lat = null; var _max_lng = null; var _min_lng = null; $.each(arr, function(idx, val) { var __lat = parseFloat(val.coordinate_lat); var __lng = parseFloat(val.coordinate_long); if (__lat > 0) { if (!_max_lat || _max_lat < __lat) _max_lat = __lat; if (!_min_lat || _min_lat > __lat) _min_lat = __lat; } if (__lng > 0) { if (!_max_lng || _max_lng < __lng) _max_lng = __lng; if (!_min_lng || _min_lng > __lng) _min_lng = __lng; } }); var southwest = new google.maps.LatLng(_max_lat, _min_lng); var northeast = new google.maps.LatLng(_min_lat, _max_lng); var bounds = new google.maps.LatLngBounds(southwest, northeast); map.fitBounds(bounds); /* map.setCenter(new google.maps.LatLng((_max_lat + _min_lat) / 2, (_max_lng + _min_lng) / 2)); */ }