Skip to content

Commit 0e0f053

Browse files
committed
Map: Show balloons instead of hints on mobile devices (fix #51)
1 parent 5a76111 commit 0e0f053

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

3wifi.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
$callback = $_GET['callback'];
5555
$clat = (float)$_GET['clat'];
5656
$clon = (float)$_GET['clon'];
57+
$mob = (isset($_GET['mobile']) ? (bool)$_GET['mobile'] : false);
5758
$scat = (isset($_GET['scat']) ? (bool)$_GET['scat'] : false);
5859

5960
if (!db_connect())
@@ -108,7 +109,8 @@
108109
$ap['options']['iconColor'] = '#FF1E1E';
109110
}
110111

111-
$ap['properties']['hintContent'] = '';
112+
$propContent = ($mob ? 'balloonContent' : 'hintContent');
113+
$ap['properties'][$propContent] = '';
112114
if (!empty($cluster['bssids']))
113115
{
114116
$hints = array();
@@ -138,7 +140,7 @@
138140
$hints[] = implode('<br>', $aphint);
139141
}
140142
}
141-
$ap['properties']['hintContent'] = implode('<hr>', $hints);
143+
$ap['properties'][$propContent] = implode('<hr>', $hints);
142144
}
143145
$json['data']['features'][] = $ap;
144146
}

map.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@
1717

1818
var showaps = settingsGetBool('3wifi.map.showaps', true);
1919
var clusters = settingsGetBool('3wifi.map.clusters', true);
20+
var mob = isMobile();
21+
if (mob) myTileUrl += '&mobile=1';
2022
if (!clusters) myTileUrl += '&scat=1';
2123

2224
remoteObjectManager = new ymaps.RemoteObjectManager(myTileUrl,
2325
{ // Разбивать запросы по тайлам
2426
splitRequests: false,
2527
// Опции кластеров задаются с префиксом cluster.
2628
clusterHasBalloon: false,
27-
clusterHasHint: true,
29+
clusterHasHint: !mob,
2830
// Опции объектов задаются с префиксом geoObject
29-
geoObjectOpenBalloonOnClick: false
31+
geoObjectOpenBalloonOnClick: mob
3032
});
3133

32-
userLocations = new ymaps.RemoteObjectManager('user.php?a=mylocmap&bbox=%b',
34+
userLocations = new ymaps.RemoteObjectManager('user.php?a=mylocmap&bbox=%b' + (mob ? '&mobile=1' : ''),
3335
{ // Разбивать запросы по тайлам
3436
splitRequests: false,
3537
// Опции объектов задаются с префиксом geoObject
36-
geoObjectOpenBalloonOnClick: false
38+
geoObjectOpenBalloonOnClick: mob
3739
});
3840

3941
if (ProfileInfo.Level >= 1)

user.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ function getFloatCoord($coord)
592592
$lat2 = (float)$bbox[2];
593593
$lon2 = (float)$bbox[3];
594594
$callback = $_GET['callback'];
595+
$mob = (isset($_GET['mobile']) ? (bool)$_GET['mobile'] : false);
595596
$uid = $UserManager->uID;
596597
if (!$res = QuerySql("SELECT latitude,longitude,comment FROM locations WHERE uid=$uid AND latitude BETWEEN $lat1 AND $lat2 AND longitude BETWEEN $lon1 AND $lon2"))
597598
{
@@ -606,12 +607,13 @@ function getFloatCoord($coord)
606607
$loc['type'] = 'Feature';
607608
$loc['options']['iconColor'] = '#00D000';
608609
$loc['geometry']['type'] = 'Point';
610+
$propContent = ($mob ? 'balloonContent' : 'hintContent');
609611
while ($row = $res->fetch_row())
610612
{
611613
$loc['geometry']['coordinates'][0] = (float)$row[0];
612614
$loc['geometry']['coordinates'][1] = (float)$row[1];
613615
$loc['id'] = 'loc'.substr(md5($row[0].$row[1]), 0, 4);
614-
$loc['properties']['hintContent'] = '<b>Локация:</b><br>'.htmlspecialchars($row[2]);
616+
$loc['properties'][$propContent] = '<b>Локация:</b><br>'.htmlspecialchars($row[2]);
615617
$json['data']['features'][] = $loc;
616618
}
617619
$res->close();

0 commit comments

Comments
 (0)