Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URL Transform, Zoom behavior #39

Merged
merged 4 commits into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mapboxgl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .viz import CircleViz, GraduatedCircleViz, HeatmapViz, ClusteredCircleViz

__version__ = "0.1.2"
__version__ = "0.1.3"
__all__ = ['CircleViz', 'GraduatedCircleViz', 'HeatmapViz', 'ClusteredCircleViz']
13 changes: 10 additions & 3 deletions mapboxgl/templates/circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
});
Expand Down Expand Up @@ -91,7 +98,7 @@
map.on('click', 'circle', function(e) {
map.flyTo({
center: e.features[0].geometry.coordinates,
zoom: 10
zoom: map.getZoom() + 1
});
});
});
Expand Down
20 changes: 17 additions & 3 deletions mapboxgl/templates/clustered_circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
});
Expand Down Expand Up @@ -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
});
});
});
Expand Down
13 changes: 10 additions & 3 deletions mapboxgl/templates/graduated_circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
});
Expand Down Expand Up @@ -92,7 +99,7 @@
map.on('click', 'circle', function(e) {
map.flyTo({
center: e.features[0].geometry.coordinates,
zoom: 10
zoom: map.getZoom() + 1
});
});
});
Expand Down
11 changes: 9 additions & 2 deletions mapboxgl/templates/heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
});
Expand Down