upgraded to the latest mapbox-gl js files
This commit is contained in:
parent
ab440de1a2
commit
71a93298f2
|
|
@ -40,9 +40,9 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.min.js" integrity="sha512-SeiQaaDh73yrb56sTW/RgVdi/mMqNeM2oBwubFHagc5BkixSpP1fvqF47mKzPGWYSSy4RwbBunrJBQ4Co8fRWA==" crossorigin="anonymous"></script>
|
||||
|
||||
<?php if ($mapapi == 'leaflet-vector'): ?>
|
||||
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.35.1/mapbox-gl.css" rel='stylesheet' />
|
||||
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.35.1/mapbox-gl.js"></script>
|
||||
<script src="https://unpkg.com/mapbox-gl-leaflet@0.0.3/leaflet-mapbox-gl.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/1.13.1/mapbox-gl.min.css" />
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/1.13.1/mapbox-gl.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl-leaflet/0.0.15/leaflet-mapbox-gl.min.js"></script>
|
||||
<?php endif; ?>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-providers/1.11.0/leaflet-providers.min.js" integrity="sha512-TO+Wd5hbpDsACTmvzSqAZL83jMQCXGRFNoS4WZxcxrlJBTdgMYaT7g5uX49C5+Kbuxzlg2A+TFJ6UqdsXuOKLw==" crossorigin="anonymous"></script>
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ var currentFilterStationIds=this._map.state.getFilterStationIds();if(currentFilt
|
|||
this._setWebsocketStateLoading(false);this._websocket.doSendFilterRequestByName(stationNameArray,this._map.state.getTimeLength()/60,this.getTimeTravelTimestamp());},stopTrackStation:function(){this._map.state.onlyTrackRecentPackets=false;this._map.state.trackStationId=null;this._emitEventListeners("track-changed",[null,null]);},trackStation:function(stationId,stationName,alsoFilterOnStation,onlyTrackRecentPackets){onlyTrackRecentPackets=typeof onlyTrackRecentPackets!=="undefined"?onlyTrackRecentPackets:false;if(alsoFilterOnStation){var currentFilterStationIds=this._map.state.getFilterStationIds();if(currentFilterStationIds.length>0){if(currentFilterStationIds.indexOf(stationId)==-1){this.filterOnStationId(stationId);}}}
|
||||
if(stationId!==null){var trackLinkElementClass="trackStationLink"+stationId;$("."+trackLinkElementClass).html("Untrack");}
|
||||
if(this._map.state.trackStationId!==null){var trackLinkElementClass="trackStationLink"+this._map.state.trackStationId;$("."+trackLinkElementClass).html("Track");}
|
||||
this._map.state.onlyTrackRecentPackets=onlyTrackRecentPackets;this._map.state.trackStationId=stationId;this._emitEventListeners("track-changed",[stationId,stationName]);},focusOnStation:function(stationId,openInfoWindow){var map=this._map;openInfoWindow=typeof openInfoWindow!=="undefined"?openInfoWindow:false;var marker=map.markerCollection.getStationLatestMarker(stationId);if(marker!==null){marker.show();marker.showLabel();if(openInfoWindow){map.openMarkerInfoWindow(marker,false);}else{this.setCenter(marker.packet.latitude,marker.packet.longitude,this.settings.defaultCurrentZoom);}
|
||||
marker.hide(5000,true);}},focusOnMarkerId:function(markerId,zoom){var map=this._map;var markerIdKey=map.markerCollection.getMarkerIdKey(markerId);if(map.markerCollection.isExistingMarker(markerIdKey)){var marker=map.markerCollection.getMarker(markerIdKey);if(map.markerCollection.hasRelatedDashedPolyline(marker)){newerMarker=map.markerCollection.getMarker(marker._relatedMarkerOriginDashedPolyLine.ownerMarkerIdKey);if(newerMarker.packet.hasConfirmedMapId()){return this.focusOnMarkerId(newerMarker.packet.marker_id);}}
|
||||
this._map.state.onlyTrackRecentPackets=onlyTrackRecentPackets;this._map.state.trackStationId=stationId;this._emitEventListeners("track-changed",[stationId,stationName]);},focusOnStation:function(stationId,openInfoWindow){var map=this._map;openInfoWindow=typeof openInfoWindow!=="undefined"?openInfoWindow:false;var marker=map.markerCollection.getStationLatestMarker(stationId);if(marker!==null){marker.show();marker.showLabel();if(openInfoWindow){map.openMarkerInfoWindow(marker,false);}else{this.setCenter(marker.packet.latitude,marker.packet.longitude);}
|
||||
marker.hide(5000,true);return true;}else{return false;}},focusOnMarkerId:function(markerId,zoom){var map=this._map;var markerIdKey=map.markerCollection.getMarkerIdKey(markerId);if(map.markerCollection.isExistingMarker(markerIdKey)){var marker=map.markerCollection.getMarker(markerIdKey);if(map.markerCollection.hasRelatedDashedPolyline(marker)){newerMarker=map.markerCollection.getMarker(marker._relatedMarkerOriginDashedPolyLine.ownerMarkerIdKey);if(newerMarker.packet.hasConfirmedMapId()){return this.focusOnMarkerId(newerMarker.packet.marker_id);}}
|
||||
marker.show();marker.showLabel();this.setCenter(marker.packet.latitude,marker.packet.longitude,zoom);map.openMarkerInfoWindow(marker);marker.hide(5000,true);}},toggleStationCoverage:function(stationId,coverageLinkElementClass){coverageLinkElementClass=typeof coverageLinkElementClass!=="undefined"?coverageLinkElementClass:null;var coveragePolygon=this._map.markerCollection.getStationCoverage(stationId);if(coveragePolygon!==null&&coveragePolygon.isRequestedToBeVisible()){coveragePolygon.hide();if(coverageLinkElementClass!==null){$("."+coverageLinkElementClass).html("Coverage");}}else{if(coveragePolygon!==null){coveragePolygon.show();if(!coveragePolygon.hasContent()){alert("Currently we do not have enough data to create a max range coverage plot for this station. Try again later!");}else{if(coverageLinkElementClass!==null){$("."+coverageLinkElementClass).html("Hide coverage");}}}else{var packet=this._map.markerCollection.getStationLatestPacket(stationId);var center={lat:parseFloat(packet.latitude),lng:parseFloat(packet.longitude),};var coveragePolygon=new trackdirect.models.StationCoveragePolygon(center,this._map,true);this._map.markerCollection.addStationCoverage(stationId,coveragePolygon);coveragePolygon.showWhenDone();if(coverageLinkElementClass!==null){$("."+coverageLinkElementClass).html('Loading <i class="fa fa-spinner fa-spin" style="font-size:12px"></i>');coveragePolygon.addTdListener("visible",function(){if(!coveragePolygon.hasContent()){coveragePolygon.hide();alert("Currently we do not have enough data to create a max range coverage plot for this station. Try again later!");$("."+coverageLinkElementClass).html("Coverage");}else{$("."+coverageLinkElementClass).html("Hide coverage");}},true);}
|
||||
var me=this;$.getJSON(this.coverageDataUrl+"?id="+stationId,function(data){if("station_id"in data&&"coverage"in data){coveragePolygon.setData(data["coverage"],me.coveragePercentile);var marker=me._map.markerCollection.getStationLatestMarker(stationId);if(marker.isVisible()){if(coveragePolygon.isRequestedToBeVisible()){coveragePolygon.show();}}}}).fail(function(){coveragePolygon.hide();alert("Failed to fetch coverage data. Try again later!");$("."+coverageLinkElementClass).html("Coverage");}).always(function(){});}}},setMapType:function(mapType){if(this._map!==null){this._map.setMapType(mapType);}},getMapType:function(){if(this._map!==null){return this._map.getMapType();}},setMapDefaultLocation:function(setDefaultZoom){this._map.setMapDefaultLocation(setDefaultZoom);},setMapLocationByGeoLocation:function(failCallBack,successCallBack,timeout){var me=this;if(navigator&&navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){var pos={lat:position.coords.latitude,lng:position.coords.longitude,};me._map.setCenter(pos,12);if(successCallBack!==null){successCallBack();}},function(error){if(failCallBack!==null){failCallBack(error.message);}},{enableHighAccuracy:false,timeout:timeout,maximumAge:5000,});}else{if(failCallBack!==null){failCallBack();}}},openStationInformationDialog:function(stationId){var packet=this._map.markerCollection.getStationLatestPacket(stationId);if(packet==null){packet={station_id:stationId,id:null};}
|
||||
this._emitEventListeners("station-name-clicked",packet);},openMarkerInfoWindow:function(markerId){var markerIdKey=this._map.markerCollection.getMarkerIdKey(markerId);if(this._map.markerCollection.isExistingMarker(markerIdKey)){var marker=this._map.markerCollection.getMarker(markerIdKey);this._map.openMarkerInfoWindow(marker);}},closeAnyOpenInfoWindow:function(){if(this._map!==null){var state=this._map.state;if(state.isInfoWindowOpen()){state.openInfoWindow.hide();}}},setTimeTravelTimestamp:function(ts,sendRequestToServer){if(ts!=0||this._map.state.endTimeTravelTimestamp!=null){sendRequestToServer=typeof sendRequestToServer!=="undefined"?sendRequestToServer:true;if(this._map.state.endTimeTravelTimestamp!=ts){if(ts!=null&&ts!=0&&ts!=""){this._map.state.endTimeTravelTimestamp=ts;}else{this._map.state.endTimeTravelTimestamp=null;}
|
||||
|
|
@ -611,7 +611,7 @@ this._addInfoWindowListeners(this.state.openInfoWindow);this.state.openInfoWindo
|
|||
this.state.openInfoWindow=new trackdirect.models.InfoWindow(marker,this);this._addInfoWindowListeners(this.state.openInfoWindow);this.state.openInfoWindow.show(true,position);};trackdirect.models.Map.prototype._addInfoWindowListeners=function(infoWindow){var me=this;infoWindow.addTdListener("station-tail-needed",function(stationId){me._emitTdEventListeners("station-tail-needed",stationId);});};(trackdirect.models.Map.prototype.addTdListener=function(event,handler){if(!(event in this._tdEventListeners)){this._tdEventListeners[event]=[];}
|
||||
this._tdEventListeners[event].push(handler);}),(trackdirect.models.Map.prototype._emitTdEventListeners=function(event,arg){if(event in this._tdEventListeners){for(var i=0;i<this._tdEventListeners[event].length;i++){this._tdEventListeners[event][i](arg);}}});(trackdirect.models.Map.prototype._triggerMapChangeEvent=function(){if(this._tdEventTimeout!=null){clearTimeout(this._tdEventTimeout);}
|
||||
var me=this;this._tdEventTimeout=window.setTimeout(function(){me._emitTdEventListeners("change");me._tdEventTimeout=null;},5);}),(trackdirect.models.Map.prototype._deactivateHeatMap=function(){if(typeof google==="object"&&typeof google.maps==="object"){if(typeof this.overlayMapTypes!=="undefined"&&this.overlayMapTypes.length>0){this.overlayMapTypes.clear();}}else if(typeof L==="object"){if(this._heatMap!==null){this.removeLayer(this._heatMap);}}});trackdirect.models.Map.prototype._activateHeatMap=function(){if(typeof google==="object"&&typeof google.maps==="object"){if(typeof this.overlayMapTypes!=="undefined"&&this.overlayMapTypes.length==0){this.overlayMapTypes.setAt(0,this._heatMap);}}else if(typeof L==="object"){if(this._heatMap!==null){this._heatMap.addTo(this);this._heatMap.bringToFront();this._heatMap.setZIndex(1000);}}};trackdirect.models.Map.prototype._updateGoogleMapTileLayer=function(){this.setMapTypeId(this._supportedMapTypes[this._mapType]);};trackdirect.models.Map.prototype._updateLeafletTileLayer=function(){if(typeof windyInit!=="function"){if(this._leafletTileLayer!==null){this._leafletTileLayer.remove();}
|
||||
if(typeof L.mapboxGL==="function"){var attribution="";var accessToken="no-token";var style="https://api.maptiler.com/maps/basic/style.json?optimize=true&key=MYwA9fnolsOrAYyiBx6J";if("mapboxGLStyle"in this._tdMapOptions){style=this._tdMapOptions["mapboxGLStyle"];}
|
||||
if(typeof L.mapboxGL==="function"){var attribution="";var accessToken="no-token";var style="";if("mapboxGLStyle"in this._tdMapOptions){style=this._tdMapOptions["mapboxGLStyle"];}
|
||||
if("mapboxGLAccessToken"in this._tdMapOptions){accessToken=this._tdMapOptions["mapboxGLAccessToken"];}
|
||||
if("mapboxGLAttribution"in this._tdMapOptions){attribution=this._tdMapOptions["mapboxGLAttribution"];}
|
||||
this._leafletTileLayer=L.mapboxGL({accessToken:accessToken,style:style,});this.addLayer(this._leafletTileLayer);this.attributionControl.addAttribution(attribution);}else{var options={};if(isHighDensity()){options["ppi"]="320";options["size"]="512";}else if(trackdirect.isMobile){options["ppi"]="250";}
|
||||
|
|
|
|||
|
|
@ -645,8 +645,7 @@ trackdirect.models.Map.prototype._updateLeafletTileLayer = function () {
|
|||
if (typeof L.mapboxGL === "function") {
|
||||
var attribution = "";
|
||||
var accessToken = "no-token";
|
||||
var style =
|
||||
"https://api.maptiler.com/maps/basic/style.json?optimize=true&key=MYwA9fnolsOrAYyiBx6J";
|
||||
var style = "";
|
||||
|
||||
if ("mapboxGLStyle" in this._tdMapOptions) {
|
||||
style = this._tdMapOptions["mapboxGLStyle"];
|
||||
|
|
|
|||
Loading…
Reference in New Issue