I have this array as latitude and longitude marker.
How to skip marker that are close in range about 5 to 10 meter?
getting array from text.file
[{"referid":"3913","categoryid":"393","latitude":"-6.25424783405257","longitude":"106.827406067554","image_name":"IMG_20150429_115341_2613531.jpg","upload_date":"2015-04-29 11:54:26","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.37, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25431960585217","longitude":"106.827667078023","image_name":"IMG_20150429_115820_699264.jpg","upload_date":"2015-04-29 12:00:27","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.31-35, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.2543484143375","longitude":"106.82757439518","image_name":"IMG_20150429_120117_8379184.jpg","upload_date":"2015-04-29 12:01:24","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.31-35, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25422984183592","longitude":"106.827929714578","image_name":"IMG_20150429_120502_9778844.jpg","upload_date":"2015-04-29 12:06:10","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.37, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25474628069748","longitude":"106.833319851496","image_name":"IMG_20150429_121045_1525027.jpg","upload_date":"2015-04-29 12:13:34","description":"Cluster Kemang3 - Segment1","address":"Jalan Jatiluhur No.3, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25424629718876","longitude":"106.827906626936","image_name":"IMG_20150429_122545_9863722.jpg","upload_date":"2015-04-29 12:25:37","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.37, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.2542312339466","longitude":"106.829570964473","image_name":"IMG_20150429_123103_7950591.jpg","upload_date":"2015-04-29 12:30:57","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.36, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25422328260916","longitude":"106.830807439673","image_name":"IMG_20150429_123231_1865120.jpg","upload_date":"2015-04-29 12:32:30","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.28A, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.2541989248936","longitude":"106.831558130415","image_name":"IMG_20150429_123453_3663043.jpg","upload_date":"2015-04-29 12:34:42","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.25, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25404510111961","longitude":"106.832625584677","image_name":"IMG_20150429_123904_7222461.jpg","upload_date":"2015-04-29 12:39:06","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.20, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25430714705277","longitude":"106.834101063251","image_name":"IMG_20150429_124305_626938.jpg","upload_date":"2015-04-29 12:42:55","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Raya No.103, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25535251958435","longitude":"106.8332994886","image_name":"IMG_20150429_124522_8616255.jpg","upload_date":"2015-04-29 12:45:34","description":"Cluster Kemang3 - Segment1","address":"Jalan Laboratorium No.3-4, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25584361810927","longitude":"106.8325887258","image_name":"IMG_20150429_125059_7300602.jpg","upload_date":"2015-04-29 12:50:54","description":"Cluster Kemang3 - Segment1","address":"Jalan Jatiluhur No.15, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25491599036074","longitude":"106.832590131487","image_name":"IMG_20150429_125502_292609.jpg","upload_date":"2015-04-29 12:54:53","description":"Cluster Kemang3 - Segment1","address":"Jalan Jatiluhur No.2, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25508057968553","longitude":"106.832552204924","image_name":"IMG_20150429_130516_1339514.jpg","upload_date":"2015-04-29 13:05:10","description":"Cluster Kemang3 - Segment1","address":"Jalan Jatiluhur No.2, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3913","categoryid":"393","latitude":"-6.25484413612163","longitude":"106.831568364522","image_name":"IMG_20150429_130831_5809511.jpg","upload_date":"2015-04-29 13:08:26","description":"Cluster Kemang3 - Segment1","address":"Jalan Duren Tiga Utara I, Pancoran, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12760, Republic of Indonesia","username":"herfan"},{"referid":"3983","categoryid":"463","latitude":"-6.20259166666667","longitude":"106.840436666667","image_name":"IMG_20150429_132648_7141021.jpg","upload_date":"2015-04-29 13:28:18","description":"Cluster Menteng1 - Segment1","address":"Jalan Ki Mangun Sarkoro No.46, Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10310, Republic of Indonesia","username":"Eddy JTIM"},{"referid":"3983","categoryid":"463","latitude":"-6.20324166666667","longitude":"106.84073","image_name":"IMG_20150429_133126_3254505.jpg","upload_date":"2015-04-29 13:34:39","description":"Cluster Menteng1 - Segment1","address":"Jalan Sukabumi No.6-8, Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10310, Republic of Indonesia","username":"Eddy JTIM"},{"referid":"3983","categoryid":"463","latitude":"-6.20258","longitude":"106.841428333333","image_name":"IMG_20150429_133907_1501770.jpg","upload_date":"2015-04-29 13:40:51","description":"Cluster Menteng1 - Segment1","address":"Jalan Ki Mangun Sarkoro No.79, Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10310, Republic of Indonesia","username":"Eddy JTIM"},{"referid":"3983","categoryid":"463","latitude":"-6.20364333333333","longitude":"106.841205","image_name":"IMG_20150429_134246_3636588.jpg","upload_date":"2015-04-29 13:44:02","description":"Cluster Menteng1 - Segment1","address":"Jalan Sukabumi No.11, Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10310, Republic of Indonesia","username":"Eddy JTIM"},{"referid":"3983","categoryid":"463","latitude":"-6.20402833333333","longitude":"106.84157","image_name":"IMG_20150429_134625_2710502.jpg","upload_date":"2015-04-29 13:52:28","description":"Cluster Menteng1 - Segment1","address":"Jalan Sukabumi No.17, Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10310, Republic of Indonesia","username":"Eddy JTIM"}]
and here is my php files
<?php
$connected = @fsockopen("www.google.com", 80);
if (!$connected) {
echo "<script>alert('need internet connection');</script>";
}
else {
$getmarker = file_get_contents('json.txt');
$jsonmarker = json_decode($getmarker);
$arraylat = array();
for ($a=0; $a < count($jsonmarker); $a++) {
$stdlat = substr($jsonmarker[$a]->latitude, 0, (strpos($jsonmarker[$a]->latitude, '.', 1) + 8));
$stdlon = substr($jsonmarker[$a]->longitude, 0, (strpos($jsonmarker[$a]->longitude, '.', 1) + 8));
switch (strlen($stdlat)) {
case 10:
$fixlat = floatval($stdlat);
$fixlon = floatval($stdlon);
break;
case 9:
$fixlat = floatval($stdlat.'0');
$fixlon = floatval($stdlon.'0');
break;
case 8:
$fixlat = floatval($stdlat.'00');
$fixlon = floatval($stdlon.'00');
break;
case 7:
$fixlat = floatval($stdlat.'000');
$fixlon = floatval($stdlon.'000');
break;
case 6:
$fixlat = floatval($stdlat.'0000');
$fixlon = floatval($stdlon.'0000');
break;
case 5:
$fixlat = floatval($stdlat.'00000');
$fixlon = floatval($stdlon.'00000');
break;
case 4:
$fixlat = floatval($stdlat.'000000');
$fixlon = floatval($stdlon.'000000');
break;
}
array_push($arraylat, $fixlat.', '.$fixlon);
}
$slice = array_slice($jsonmarker, 0, 20);
$markers = "";
for ($i=0; $i < count($jsonmarker); $i++) {
$markers .= "[".$jsonmarker[$i]->referid.", ".$jsonmarker[$i]->categoryid.", ".$jsonmarker[$i]->latitude.", ".$jsonmarker[$i]->longitude."
, , '".date("d M Y H:i:s", strtotime($jsonmarker[$i]->upload_date))."', '".$jsonmarker[$i]->description."'
, '".$jsonmarker[$i]->address."', '".$jsonmarker[$i]->username."'], ";
$centermap = $jsonmarker[$i]->latitude.", ".$jsonmarker[$i]->longitude;
}
$cleanmarkers = rtrim($markers, ', ');
$arrlatdif = array();
$moveingno = array();
foreach ($arraylat as $key => $value) {
array_push($moveingno, $key);
foreach ($arraylat as $k => $v) {
$dif = (-1 * $value) - (-1 * $v);
if ($value != $v && $value != in_array($k, $moveingno) && $dif < 0.0001 && $dif > -0.0001) {
array_push($arrlatdif, 'index '.$key.' similiar to index '.$k.' on latitude '.$v);
}
}
}
echo "this loop for reduce similiar value<br><pre>",print_r($arrlatdif),"</pre>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>MoraMaps</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/jquery-ui.js"></script>
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<!-- fancybox on arhgreat -->
<link rel="stylesheet" href="./css/jquery.fancybox.css" type="text/css" media="screen"/>
<script type="text/javascript" src="./js/jquery.fancybox.pack.js"></script>
<script>
var map;
// this where maps called
function initialize() {
var mapOptions = {
zoom: 13,
center: new google.maps.LatLng(<?php echo $centermap ?>),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
setMarkers(map, markers);
}
var markers = [<?php echo $cleanmarkers ?>];
var infowindow = new google.maps.InfoWindow();
function setMarkers(map, locations) {
var marker, i;
for (i = 0; i < locations.length; i++) {
var markers = locations[i];
var myLatLng = new google.maps.LatLng(locations[i][2], locations[i][3]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: locations[i][4],
fancyimg: locations[i][4],
icon: './images/jb.png',
content: '<b>latitude :</b>'+locations[i][2]+
'<b style=padding-left:10px;>longitude :</b>'+locations[i][3]+
'</br><b>upload date :</b>'+locations[i][5]+
'<b style=padding-left:20px;>by :</b>'+locations[i][8]+
'</br><b>description :</b>'+locations[i][6]+
'</br><b>address :</b>'+locations[i][7]+'</br>'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
$.fancybox({
type: 'iframe',
iframe:{'scrolling':'no'},
autoscale: 'true',
//href: this.fancyimg,
overlayShow: true,
centerOnScroll: true,
width: 500,
height: 600,
title: this.content,
helpers : { title : { type : 'inside' }}
});
}
})(marker, i));
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas" style="width:100%; height: 850px"></div>
<div id="dialog"></div>
<style type="text/css">
.search {
position: fixed;
border-radius: 2px;
float: left;
height: 30px;
line-height: 30px;
margin: 20px 0px 0px 80px;
padding-left: 10px;
width: 500px;
z-index: 50;
}
#searchsite {
padding: 0px 11px 0px 13px;
font-size: 15px;
border: 1px solid transparent;
border-radius: 2px 0px 0px 2px;
box-sizing: border-box;
height: 32px;
outline: medium none;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.3);
}
#searchresult {
position: fixed;
z-index: 100;
}
#panel {
position: fixed;
top: 20px;
left: 80%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid transparent;
font-family: arial, Helvetica, sans-serif;
font-size: 60%;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.3);
}
#panel3 {
position: fixed;
top: 55px;
left: 80%;
margin-left: -180px;
z-index: 5;
font-family: arial, Helvetica, sans-serif;
font-size: 75%;
height: 20px;
}
#panel3 img {
height: 18px;
border: 1px solid transparent;
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.3);
}
#dialog {
font-size: 14px;
}
</style>
</body>
</html>
still working on for loop
I think the close range is in south jakarta area
marker shown here is still from the array(from text files)
notes on abbove is my progress doing
cause no one trying to answer and just vote down to this question
so I do some little trick for this in my
.php
filesnow your marker is store in
$arraytouse
just fetch as any output form as you wanted...
hopes this help others