@@ -127,22 +127,88 @@ export default {
127127 console .error (' Failed to connect to socket' , e);
128128 }
129129 },
130+ getVehicleType (vehicle ) {
131+ if (! vehicle) {
132+ return null ;
133+ }
134+
135+ let ret = {
136+ type: ' car' ,
137+ size: 23
138+ };
139+
140+ $ .each (custom_icons, function (type , cfg ) {
141+ if (cfg .models .includes (vehicle .model )) {
142+ ret .type = type;
143+ ret .size = cfg .size ;
144+ }
145+ });
146+
147+ return ret;
148+ },
149+ getIcon (player , isDriving , isPassenger , isInvisible ) {
150+ let size = {
151+ circle: 17 ,
152+ circle_red: 12 ,
153+ circle_green: 13
154+ };
155+
156+ let icon = new L.Icon (
157+ {
158+ iconUrl: ' /images/circle.png' ,
159+ iconSize: [size .circle , size .circle ]
160+ }
161+ );
162+
163+ if (isInvisible) {
164+ icon = new L.Icon (
165+ {
166+ iconUrl: ' /images/circle_green.png' ,
167+ iconSize: [size .circle_green , size .circle_green ]
168+ }
169+ );
170+ } else if (isDriving) {
171+ const info = this .getVehicleType (player .vehicle );
172+
173+ icon = new L.Icon (
174+ {
175+ iconUrl: ' /images/' + info .type + ' .png' ,
176+ iconSize: [info .size , info .size ]
177+ }
178+ );
179+ } else if (isPassenger) {
180+ icon = new L.Icon (
181+ {
182+ iconUrl: ' /images/circle_red.png' ,
183+ iconSize: [size .circle_red , size .circle_red ]
184+ }
185+ )
186+ }
187+
188+ return icon;
189+ },
130190 renderMapData (data ) {
131191 if (this .isPaused ) {
132192 return ;
133193 }
134194
195+ if (this .trackedPlayer && this .trackedPlayer in this .markers ) {
196+ this .map .dragging .disable ();
197+ } else {
198+ this .map .dragging .enable ();
199+ }
200+
135201 const conf = {
136202 game: {
137203 bounds: {
138- min: {x: - 2870 , y: 7000 },
139- max: {x: 4000 , y: - 3500 }
204+ min: {x: - 2862.10546875 , y: 7616.0966796875 },
205+ max: {x: 4195.29248046875 , y: - 3579.89013671875 }
140206 }
141207 },
142208 map: {
143209 bounds: {
144- min: {x: 85.5 , y: - 67.1 },
145- max: {x: 172.1 , y: - 199.4 }
210+ min: {x: 85.546875 , y: - 59.62890625 },
211+ max: {x: 174.2109375 , y: - 200.24609375 }
146212 }
147213 }
148214 };
@@ -153,60 +219,6 @@ export default {
153219
154220 return _this .coords (coords);
155221 };
156- const getIcon = (player , isDriving , isPassenger , isInvisible ) => {
157- const zoom = _this .map .getZoom ();
158- const zoomModifier = zoom === 7 ? 1.2 : 1 ;
159- let size = {
160- car: 23 ,
161- circle: 17 ,
162- circle_red: 12 ,
163- circle_green: 13
164- };
165-
166- let icon = new L.Icon (
167- {
168- iconUrl: ' /images/circle.png' ,
169- iconSize: [size .circle * zoomModifier, size .circle * zoomModifier],
170- iconAnchor: [(size .car * zoomModifier) / 2 , (size .car * zoomModifier) / 2 ]
171- }
172- );
173-
174- if (isInvisible) {
175- icon = new L.Icon (
176- {
177- iconUrl: ' /images/circle_green.png' ,
178- iconSize: [size .circle_green * zoomModifier, size .circle_green * zoomModifier],
179- iconAnchor: [(size .car * zoomModifier) / 2 , (size .car * zoomModifier) / 2 ]
180- }
181- );
182- } else if (isDriving) {
183- let iconImage = ' car.png' ;
184- $ .each (custom_icons, function (image , cfg ) {
185- if (cfg .models .includes (player .vehicle .model )) {
186- iconImage = image;
187- size .car = cfg .size ;
188- }
189- });
190-
191- icon = new L.Icon (
192- {
193- iconUrl: ' /images/' + iconImage,
194- iconSize: [size .car * zoomModifier, size .car * zoomModifier],
195- iconAnchor: [(size .car * zoomModifier) / 2 , (size .car * zoomModifier) / 2 ]
196- }
197- );
198- } else if (isPassenger) {
199- icon = new L.Icon (
200- {
201- iconUrl: ' /images/circle_red.png' ,
202- iconSize: [size .circle_red * zoomModifier, size .circle_red * zoomModifier],
203- iconAnchor: [(size .car * zoomModifier) / 2 , (size .car * zoomModifier) / 2 ]
204- }
205- )
206- }
207-
208- return icon;
209- };
210222
211223 if (data && Array .isArray (data)) {
212224 if (this .map ) {
@@ -229,7 +241,6 @@ export default {
229241 data[index] = player
230242 });
231243
232- let hasTracked = false ;
233244 let validIds = [];
234245 $ .each (data, function (_ , player ) {
235246 const id = " player_" + player .character .id ,
@@ -239,7 +250,8 @@ export default {
239250 isPassenger = ' vehicle' in player && player .vehicle && ! player .vehicle .driving ,
240251 isInvisible = ' invisible' in player && player .invisible ,
241252 speed = ' vehicle' in player && player .vehicle && ' speed' in player .vehicle ? player .vehicle .speed : null ,
242- icon = getIcon (player, isDriving, isPassenger, isInvisible);
253+ icon = _this .getIcon (player, isDriving, isPassenger, isInvisible),
254+ vehicle = _this .getVehicleType (player .vehicle );
243255
244256 validIds .push (id);
245257
@@ -273,7 +285,7 @@ export default {
273285 markers[id].options .forceZIndex = 101 ;
274286 }
275287 if (isDriving) {
276- attributes .push (' driving' );
288+ attributes .push (' driving ( ' + vehicle . type + ' ) ' );
277289 markers[id].options .forceZIndex = 100 ;
278290 } else if (isPassenger) {
279291 attributes .push (' passenger of ' + (player .vehicle .id in vehicles ? vehicles[player .vehicle .id ] : ' Nobody' ));
@@ -286,20 +298,14 @@ export default {
286298 if (_this .trackedPlayer === id) {
287299 extra += ' <br><br><a href="#" class="track-cid" data-trackid="stop"">' + _this .t (' map.stop_track' ) + ' </a>' ;
288300
289- _this .map .dragging .disable ();
290301 _this .map .setView (coords, _this .firstRefresh ? 6 : _this .map .getZoom ());
291- hasTracked = true ;
292302 } else {
293303 extra += ' <br><br><a href="#" class="track-cid" data-trackid="' + id + ' "">' + _this .t (' map.track' ) + ' </a>' ;
294304 }
295305
296306 markers[id]._popup .setContent (player .character .fullName + ' (<a href="/players/' + player .steamIdentifier + ' ">#' + player .character .id + ' </a>)' + extra);
297307 });
298308
299- if (! hasTracked) {
300- this .map .dragging .enable ();
301- }
302-
303309 $ .each (markers, function (id , marker ) {
304310 if (! validIds .includes (id)) {
305311 _this .map .removeLayer (marker);
@@ -405,6 +411,8 @@ export default {
405411 _this .map .closePopup ();
406412 }
407413 });
414+
415+ $ (' #map' ).append (' <style>.leaflet-marker-icon {transform-origin: center center !important;}</style>' );
408416 }
409417 },
410418 mounted () {
0 commit comments