Commit bf175159 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

token loading

parent bd5ccad1
[Dolphin]
PreviewsShown=true
SortRole=date
Timestamp=2017,6,7,11,0,36
Version=3
ViewMode=1
...@@ -9,9 +9,26 @@ var map_autofit = true; ...@@ -9,9 +9,26 @@ var map_autofit = true;
var BLOCK_MOVEEND = false; var BLOCK_MOVEEND = false;
var mbxtoken = "";
$(function(){ $(function(){
//init(); //init();
$.ajax({
url: "mapbox_token.txt",
success: function(token){
mbxtoken = token;
init();
},
error: function(response){
init();
}
});
});
function init(){
parseURL(); parseURL();
init_maps(); init_maps();
init_help(); init_help();
...@@ -23,21 +40,16 @@ $(function(){ ...@@ -23,21 +40,16 @@ $(function(){
} }
$.ajax({ $.ajax({
url: url, url: url,
success: function(response){ success: function(response){
List = response; List = response;
if (map_autofit) fit_map(response); if (map_autofit) fit_map(response);
parse_list(response); parse_list(response);
init_dragging(); init_dragging();
map.fire('moveend'); map.fire('moveend');
} }
}); });
}
});
var SETTINGS = { var SETTINGS = {
'rating':5, 'rating':5,
...@@ -452,12 +464,27 @@ function init_maps(){ ...@@ -452,12 +464,27 @@ function init_maps(){
} }
); );
map = L.map('leaflet_map',{ var mapboxattr = '<a href="https://www.mapbox.com/about/maps/" target="_blank">© Mapbox</a> <a href="https://openstreetmap.org/about/" target="_blank">© OpenStreetMap</a>';
layers:[googleSat],
zoomControl:false,
}).setView([SETTINGS.lat, SETTINGS.lng], SETTINGS.zoom);
new L.Control.Zoom({ position: 'topright' }).addTo(map); var mbxurl1 = "https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.png?access_token="+mbxtoken;
var mbxurl2 = "https://api.mapbox.com/v4/mapbox.pencil/{z}/{x}/{y}@2x.png?access_token="+mbxtoken;
var MBXTiles1 = L.tileLayer(mbxurl1,
{
maxZoom: 21,
attribution: mapboxattr
}
);
var MBXTiles2 = L.tileLayer(mbxurl2,
{
maxZoom: 21,
attribution: mapboxattr
}
);
if (mbxtoken==""){
selected_layer = googleSat;
var baseMaps = { var baseMaps = {
"Esri world imagery": Esri_WorldImagery, "Esri world imagery": Esri_WorldImagery,
...@@ -465,6 +492,26 @@ function init_maps(){ ...@@ -465,6 +492,26 @@ function init_maps(){
"Open Street Map": OSMTiles "Open Street Map": OSMTiles
}; };
}else{
selected_layer = MBXTiles1;
var baseMaps = {
"Mapbox 1": MBXTiles1,
"Mapbox 2": MBXTiles2,
"Esri world imagery": Esri_WorldImagery,
"Google": googleSat,
"Open Street Map": OSMTiles
};
}
map = L.map('leaflet_map',{
layers:[selected_layer],
zoomControl:false,
}).setView([SETTINGS.lat, SETTINGS.lng], SETTINGS.zoom);
new L.Control.Zoom({ position: 'topright' }).addTo(map);
//Esri_WorldImagery.addTo(map); //Esri_WorldImagery.addTo(map);
//googleSat.addTo(map); //googleSat.addTo(map);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
var mbxtoken = ""; var mbxtoken = "";
var LeafletObject = function(id,data,options){ var LeafletObject = function(id,data,options,callback){
var defaults = { var defaults = {
debug: true, debug: true,
...@@ -73,9 +73,11 @@ var LeafletObject = function(id,data,options){ ...@@ -73,9 +73,11 @@ var LeafletObject = function(id,data,options){
success: function(token){ success: function(token){
mbxtoken = token; mbxtoken = token;
self.initialize(); self.initialize();
callback();
}, },
error: function(response){ error: function(response){
self.initialize(); self.initialize();
callback();
} }
}); });
......
...@@ -367,10 +367,12 @@ function parse_light_init_response(response,state,mode){ ...@@ -367,10 +367,12 @@ function parse_light_init_response(response,state,mode){
Scene = new X3DOMObject(element,Data,{}); Scene = new X3DOMObject(element,Data,{});
Scene.initResize(); Scene.initResize();
Map = new LeafletObject('leaflet_map',Data,{}); Map = new LeafletObject('leaflet_map',Data,{},function(){
$.getScript("js/x3dom/x3dom-full.debug.js",function(){ $.getScript("js/x3dom/x3dom-full.debug.js",function(){
console.log("loaded x3dom");
//wait until it DOM is extended //wait until it DOM is extended
x3dom.runtime.ready = function(){ x3dom.runtime.ready = function(){
...@@ -386,6 +388,8 @@ function parse_light_init_response(response,state,mode){ ...@@ -386,6 +388,8 @@ function parse_light_init_response(response,state,mode){
}; };
}); });
});
}else{ }else{
Map.marker.setHeading(heading); Map.marker.setHeading(heading);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment