Skip to content
Permalink
Browse files

v0.4

create application
view users in map
  • Loading branch information...
Anisan committed Apr 15, 2019
1 parent 942cc8f commit 42d10f41b3628f7df9476388e89f6824b60a3e1f
No changes.
@@ -215,7 +215,29 @@ function delete_user($id) {
* @access public
*/
function usual(&$out) {
$this->admin($out);
global $ajax;
global $op;
if ($ajax) {
if (!headers_sent()) {
header ("HTTP/1.0: 200 OK\n");
header ('Content-Type: text/html; charset=utf-8');
}
if ($op=='getlocations') {
$data=array();
$markers=SQLSelect("SELECT * FROM google_locations");
$total=count($markers);
for($i=0;$i<$total;$i++) {
$markers[$i]['HTML']="<b>".$markers[$i]['NAME']."</b></br>";
$markers[$i]['HTML'].="Last update:".$markers[$i]['LASTUPDATE']."</br>";
$markers[$i]['HTML'].="Battery:".$markers[$i]['BATTLEVEL']."%";
$data['LOCATIONS'][]=$markers[$i];
}
echo json_encode($data);
}
exit;
}
}
function processSubscription($event, $details='') {
$this->getConfig();
@@ -75,7 +75,7 @@
<tbody>
[#begin LOCATIONS#]
<tr [#if WARNING=="1"#]class="danger"[#endif WARNING#]>
<td><img src="[#IMAGE#]" title="[#ID_USER#]" height="30px" onerror="this.src='../templates/google_location/none.jpg'"></td>
<td><img src="[#IMAGE#]" title="[#ID_USER#]" height="30px" onerror="this.src='/templates/google_location/none.jpg'"></td>
<td valign="top" title="[#FULLNAME#]">[#NAME#]</td>
<td valign="top"><a onclick="var url=('https://static-maps.yandex.ru/1.x/?ll=[#LON#],[#LAT#]&size=650,450&z=17&l=map&pt=[#LON#],[#LAT#],pm2blm');
$.fancybox.open({'type': 'image',src: url});return false;">
@@ -1 +1,136 @@
<!--# Action Usual #-->
<!--# Action Usual #-->
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>

<script type="text/javascript" language="javascript">
var updateTimeOut;
function resizeMap() {
$('#map').css({ 'height': (($(document).height()) - 40) + 'px', 'width': '100%' });
return false;
}
function checkMarkerExists(temp_id) {
for (var i = 0, marker; marker = map.markers[i]; i++) {
if (marker.temp_id == temp_id) return true;
}
return false;
}
function getMarkerIndex(temp_id) {
for (var i = 0, marker; marker = map.markers[i]; i++) {
if (marker.temp_id == temp_id) return i;
}
return false;
}
function updateLocations() {
var url = "?ajax=1&op=getlocations";
$.ajax({
url: url
}).done(function (data) {
var obj = jQuery.parseJSON(data);
console.log(obj);
var markers = obj.LOCATIONS;
var markersCnt = markers.length;
var myCollection = new ymaps.GeoObjectCollection();
for (var i = 0; i < markersCnt; i++) {
var marker = markers[i];
if (marker.SENDTOGPS != "1") break;
var polygonLayout = ymaps.templateLayoutFactory.createClass('<div class="placemark_layout_container"><div class="polygon_layout"><img width="42" height="42" src="'+marker.IMAGE+'"></img></div></div>');
var polygonPlacemark = new ymaps.Placemark(
[marker.LAT, marker.LON],
{
hintContent: marker.HTML
},
{
iconLayout: polygonLayout,
iconShape: {
type: 'Polygon',
coordinates: [
[[-28,-76],[28,-76],[28,-20],[12,-20],[0,-4],[-12,-20],[-28,-20]]
]
}
}
);
myCollection.add(polygonPlacemark);
}
map.geoObjects.add(myCollection);
map.setBounds(myCollection.getBounds(), {checkZoomRange:true});
//updateTimeOut = setTimeout('legendUpdate();', 5000);
});
return false;
}
var map;
var startLat = 58.5795;
var startLon = 49.6888;
// HTML5 геолокация
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
startLat = position.coords.latitude;
startLon = position.coords.longitude;
}, function () {
// ошибка геолокации
});
} else { /* Браузер не поддерживает геолокацию */ }
$(document).ready(function () {
ymaps.ready(function () {
map = new ymaps.Map('map', {
center: [startLat, startLon],
zoom: 17,
type: 'yandex#map'
});
legendUpdate();
resizeMap();
});
});
function legendUpdate() {
map.geoObjects.removeAll();
updateLocations();
return false;
}
</script>

<style>
/* Макет метки с "хвостиком" */
.polygon_layout {
position: relative;
background: #ffffff;
border: 4px solid #225D9C;
width: 50px;
height: 50px;
position: absolute;
left: -28px;
top: -76px;
color: #225D9C;
}
.polygon_layout:after, .polygon_layout:before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
.polygon_layout:after {
border-top-color: #225D9C;
border-width: 10px;
margin-left: -10px;
}
.polygon_layout:before {
border-top-color: #225D9C;
border-width: 16px;
margin-left: -16px;
}
</style>
<div id="map" style="width: 100%; height: 100%;"></div>

0 comments on commit 42d10f4

Please sign in to comment.
You can’t perform that action at this time.