Skip to content

Commit 54caf24

Browse files
committed
Release 2.6.0 LocationIntelligence-Javascript
1 parent 87b961f commit 54caf24

1 file changed

Lines changed: 40 additions & 33 deletions

File tree

src/main/javascript/geojs/v1/geoMap.js

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ See the License for the specific language governing permissions and limitations
1212
* A geoMap object
1313
* @namespace
1414
*/
15-
GEOAPIS_V1.geoMap = function(accessToken){
16-
GEOAPIS_V1.baseService.call(this, accessToken);
15+
GEOAPIS_V1.geoMap = function(apiKey){
16+
this.apiKey = apiKey;
17+
GEOAPIS_V1.baseService.call(this, '');
1718
};
1819
/**
1920
* geoMap inherits baseService
@@ -22,77 +23,83 @@ See the License for the specific language governing permissions and limitations
2223
GEOAPIS_V1_INHERIT(GEOAPIS_V1.baseService, GEOAPIS_V1.geoMap);
2324
/**
2425
* Get GeoMap (Raster)
25-
* @param String mapStyle: map style bronze/iron/steel (required)
26-
* @param String apiKey: api key for map (required)
2726
* @param String latitude: map center position latitude (required)
2827
* @param String longitude: map center position longitude (required)
2928
* @param String zoom: map zoom level (required)
3029
* @param String eleId: HTML element Id to render map (required)
30+
* @param String mapStyle: map style bronze/iron/steel (required)
3131
* @return map object
3232
*/
33-
GEOAPIS_V1.geoMap.prototype.getGeoMapRaster = function(mapStyle, apiKey, latitude, longitude, zoom, eleId){
33+
GEOAPIS_V1.geoMap.prototype.getGeoMapRaster = function(latitude, longitude, zoom, eleId, mapStyle){
3434
$('#'+eleId).html('');
3535
$( '<div></div>', {
3636
'id': 'geoAPI-geoMap-raster'
3737
}).appendTo('#'+eleId);
38+
$( '<div></div>', {
39+
'id': 'geoAPI-geoMap-raster-logo'
40+
}).appendTo('#'+eleId);
3841
$('#geoAPI-geoMap-raster').css('position', 'absolute');
3942
$('#geoAPI-geoMap-raster').css('width', '100%');
4043
$('#geoAPI-geoMap-raster').css('height', '100%');
44+
45+
$( '<img/>', {
46+
'src': 'https://developer2.pitneybowes.com/en/pitneyboweslogo.png'
47+
}).appendTo('#geoAPI-geoMap-raster-logo');
48+
$('#geoAPI-geoMap-raster-logo').css('position', 'absolute');
49+
$('#geoAPI-geoMap-raster-logo').css('bottom', '0px');
50+
$('#geoAPI-geoMap-raster-logo').css('z-index', '4');
4151

4252
var map = L.map('geoAPI-geoMap-raster');
4353
map.setView([latitude, longitude], zoom);
44-
45-
var tileLayerUrl = this.apiAddress+'/geomap/v1/tile/osm/{z}/{x}/{y}.png?api_key='+apiKey+'&theme='+mapStyle;
46-
var tileLayer = L.tileLayer(tileLayerUrl, {attribution: '<a target="_blank" href="https://carto.com/attributions">CARTO</a> | &copy; OSM contributors | <a target="_blank" href="http://mapzen.com/attributions">Mapzen</a>'}).addTo(map);
54+
55+
var tmpMapStyle = 'bronze';
56+
if(mapStyle == 'bronze' || mapStyle == 'iron' || mapStyle == 'steel'){
57+
tmpMapStyle = mapStyle;
58+
}
59+
var tileLayerUrl = this.apiAddress+'/geomap/v1/tile/osm/{z}/{x}/{y}.png?api_key='+this.apiKey+'&theme='+tmpMapStyle;
60+
var tileLayer = L.tileLayer(tileLayerUrl, {attribution: '<a target="_blank" href="https://carto.com/attributions">&copy; CARTO</a> | <a target="_blank" href="http://www.openstreetmap.org/copyright">&copy; OpenStreetMap contributors</a>'}).addTo(map);
4761
return map;
4862
};
4963
/**
5064
* Get GeoMap (Vector)
51-
* @param String mapStyle: map style bronze/iron/steel (required)
52-
* @param String apiKey: api key for map (required)
5365
* @param String latitude: map center position latitude (required)
5466
* @param String longitude: map center position longitude (required)
5567
* @param String zoom: map zoom level (required)
5668
* @param String eleId: HTML element Id to render map (required)
57-
* @param String format: MVT/GeoJSON (required)
69+
* @param String mapStyle: map style bronze/iron/steel (required)
5870
* @return map object
5971
*/
60-
GEOAPIS_V1.geoMap.prototype.getGeoMapVector = function(mapStyle, apiKey, latitude, longitude, zoom, eleId, format){
72+
GEOAPIS_V1.geoMap.prototype.getGeoMapVector = function(latitude, longitude, zoom, eleId, mapStyle){
6173
var that = this;
6274
$('#'+eleId).html('');
6375
$( '<div></div>', {
6476
'id': 'geoAPI-geoMap-vector'
6577
}).appendTo('#'+eleId);
78+
$( '<div></div>', {
79+
'id': 'geoAPI-geoMap-vector-logo'
80+
}).appendTo('#'+eleId);
6681
$('#geoAPI-geoMap-vector').css('position', 'absolute');
6782
$('#geoAPI-geoMap-vector').css('width', '100%');
6883
$('#geoAPI-geoMap-vector').css('height', '100%');
6984

85+
$( '<img/>', {
86+
'src': 'https://developer2.pitneybowes.com/en/pitneyboweslogo.png'
87+
}).appendTo('#geoAPI-geoMap-vector-logo');
88+
$('#geoAPI-geoMap-vector-logo').css('position', 'absolute');
89+
$('#geoAPI-geoMap-vector-logo').css('bottom', '0px');
90+
$('#geoAPI-geoMap-vector-logo').css('z-index', '4');
91+
7092
var map = L.map('geoAPI-geoMap-vector');
7193
map.setView([latitude, longitude], zoom);
7294

95+
var tmpMapStyle = 'bronze';
96+
if(mapStyle == 'bronze' || mapStyle == 'iron' || mapStyle == 'steel'){
97+
tmpMapStyle = mapStyle;
98+
}
7399
var tileLayer = Tangram.leafletLayer({
74-
scene: '../../lib/'+mapStyle+'.yaml',
75-
attribution: '<a target="_blank" href="https://carto.com/attributions">CARTO</a> | &copy; OSM contributors | <a target="_blank" href="http://mapzen.com/attributions">Mapzen</a>',
100+
scene: 'resources/'+tmpMapStyle+'.yaml',
101+
attribution: '<a target="_blank" href="https://carto.com/attributions">&copy; CARTO</a> | <a target="_blank" href="http://www.openstreetmap.org/copyright">&copy; OpenStreetMap contributors</a> | <a target="_blank" href="http://mapzen.com">&copy; Mapzen</a>',
76102
introspection: true
77103
}).addTo(map);
78-
79-
// set scene of the tangram layer
80-
var scene = tileLayer.scene;
81-
82-
// once the scene is completely loaded
83-
scene.subscribe({
84-
view_complete: function(){
85-
scene.config.sources.mapzen.type = format;
86-
switch(format){
87-
case "MVT":
88-
scene.config.sources.mapzen.url = that.apiAddress+ '/geomap/v1/tile/osm/{z}/{x}/{y}.mvt?api_key=' +apiKey;
89-
break;
90-
case "GeoJSON":
91-
scene.config.sources.mapzen.url = that.apiAddress+ '/geomap/v1/tile/osm/{z}/{x}/{y}.geojson?api_key=' +apiKey;
92-
break;
93-
}
94-
scene.rebuild();
95-
}
96-
});
97104
return map;
98105
};

0 commit comments

Comments
 (0)