diff --git a/mapboxgl/__init__.py b/mapboxgl/__init__.py index 8890aa3..45f167f 100644 --- a/mapboxgl/__init__.py +++ b/mapboxgl/__init__.py @@ -1,4 +1,4 @@ from .viz import CircleViz, GraduatedCircleViz, HeatmapViz, ClusteredCircleViz -__version__ = "0.1.2" +__version__ = "0.1.3" __all__ = ['CircleViz', 'GraduatedCircleViz', 'HeatmapViz', 'ClusteredCircleViz'] \ No newline at end of file diff --git a/mapboxgl/templates/circle.html b/mapboxgl/templates/circle.html index 5f73bda..8549b46 100644 --- a/mapboxgl/templates/circle.html +++ b/mapboxgl/templates/circle.html @@ -9,8 +9,15 @@ center: {{ center }}, zoom: {{ zoom }}, transformRequest: (url, resourceType)=> { - return { - url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + if ( url.slice(0,22) == 'https://api.mapbox.com' ) { + //Add Python Plugin identifier for Mapbox API traffic + return { + url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + } + } + else { + //Do not transform URL for non Mapbox GET requests + return {url: url} } } }); @@ -91,7 +98,7 @@ map.on('click', 'circle', function(e) { map.flyTo({ center: e.features[0].geometry.coordinates, - zoom: 10 + zoom: map.getZoom() + 1 }); }); }); diff --git a/mapboxgl/templates/clustered_circle.html b/mapboxgl/templates/clustered_circle.html index b8f4d9e..c616688 100644 --- a/mapboxgl/templates/clustered_circle.html +++ b/mapboxgl/templates/clustered_circle.html @@ -9,8 +9,15 @@ center: {{ center }}, zoom: {{ zoom }}, transformRequest: (url, resourceType)=> { - return { - url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + if ( url.slice(0,22) == 'https://api.mapbox.com' ) { + //Add Python Plugin identifier for Mapbox API traffic + return { + url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + } + } + else { + //Do not transform URL for non Mapbox GET requests + return {url: url} } } }); @@ -106,7 +113,14 @@ map.on('click', 'circle-unclustered', function(e) { map.flyTo({ center: e.features[0].geometry.coordinates, - zoom: 10 + zoom: map.getZoom() + 1 + }); + }); + + map.on('click', 'circle-cluster', function(e) { + map.flyTo({ + center: map.unproject(e.point), + zoom: map.getZoom() + 1 }); }); }); diff --git a/mapboxgl/templates/graduated_circle.html b/mapboxgl/templates/graduated_circle.html index 678feea..5c751a7 100644 --- a/mapboxgl/templates/graduated_circle.html +++ b/mapboxgl/templates/graduated_circle.html @@ -9,8 +9,15 @@ center: {{ center }}, zoom: {{ zoom }}, transformRequest: (url, resourceType)=> { - return { - url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + if ( url.slice(0,22) == 'https://api.mapbox.com' ) { + //Add Python Plugin identifier for Mapbox API traffic + return { + url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + } + } + else { + //Do not transform URL for non Mapbox GET requests + return {url: url} } } }); @@ -92,7 +99,7 @@ map.on('click', 'circle', function(e) { map.flyTo({ center: e.features[0].geometry.coordinates, - zoom: 10 + zoom: map.getZoom() + 1 }); }); }); diff --git a/mapboxgl/templates/heatmap.html b/mapboxgl/templates/heatmap.html index 9aa13ce..45ea6a9 100644 --- a/mapboxgl/templates/heatmap.html +++ b/mapboxgl/templates/heatmap.html @@ -9,8 +9,15 @@ center: {{ center }}, zoom: {{ zoom }}, transformRequest: (url, resourceType)=> { - return { - url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + if ( url.slice(0,22) == 'https://api.mapbox.com' ) { + //Add Python Plugin identifier for Mapbox API traffic + return { + url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') + } + } + else { + //Do not transform URL for non Mapbox GET requests + return {url: url} } } });