-
Notifications
You must be signed in to change notification settings - Fork 119
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
GeoJson plugin #38
GeoJson plugin #38
Conversation
create demo activity of GeoJson Loader plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed a part of the PR, most comments are related to codestyle, missing javadoc etc.
One thing I would like to see differently is that you are constantly using a new GeoJsonPluginBuilder. This is not ideal if a user want to constantly update their GeoJson. It would make more sense building it once and allowing to update the underlying sources direclty on the plugin. This will be faster and will result in generating less garbage.
public void onMapReady(MapboxMap mapboxMap) { | ||
this.mapboxMap = mapboxMap; | ||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(32.6546, 51.6680), 7)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit whiteline
} | ||
} | ||
}) | ||
.draw(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a builder pattern normally ends with calling a method with using the build()
method signature
} | ||
}) | ||
.draw(); | ||
requestExternalStoragePermission(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I understand requesting the external storage permissions after you have read from permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may I use https://github.com/afollestad/material-dialogs#file-selector-dialogs for selecting GeoJson file from external storage?
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) | ||
== PackageManager.PERMISSION_GRANTED) { | ||
Log.v(TAG, "Permission is granted"); | ||
//drawFromPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment, no-op
} | ||
} else { //permission is automatically granted on sdk<23 upon installation | ||
Log.v(TAG, "Permission is granted"); | ||
//drawFromPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment, no-op
@@ -0,0 +1,12 @@ | |||
package com.mapbox.mapboxsdk.plugins.geojson.listener; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
public interface OnLoadingGeoJsonListener { | ||
void onPreLoading(); | ||
|
||
void onLoaded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
package com.mapbox.mapboxsdk.plugins.geojson.listener; | ||
|
||
public interface OnLoadingGeoJsonListener { | ||
void onPreLoading(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
import org.json.JSONObject; | ||
|
||
public interface OnMarkerEventListener { | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
import com.mapbox.mapboxsdk.annotations.Marker; | ||
|
||
import org.json.JSONObject; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing javadoc
@tobrun |
LatLngBounds.Builder builder = new LatLngBounds.Builder(); | ||
try { | ||
JSONObject json = new JSONObject(geoJson); | ||
JSONArray features = json.getJSONArray("features"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an open source library that handles GeoJson transparently without the need to use the lower level JSONObject
classes. Any reason not to use for the plugin? It comes includes by default with the Maps SDK so you should be able to use it without having to add any external dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about this GeoJson handler. I just use example of this link
https://www.mapbox.com/android-sdk/examples/geojson/
Will be replacing.
Thanks for your review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bkhezry Thank you! We'll definitely update that example to use the library I was mentioning, good catch.
replace Log with Timber. add setUrl, setAssetsName & setFilePath functions to the GeoJsonPlugin. and fixed other reviews.
almost of review have been fixed.
with multiple Polygon or Polyline in GeoJson file, selecting random color may be useful.
manual parsing GeoJson string replaced with SDK of Mapbox. |
Hey @bkhezry, sorry this plugin is taking some time to review, we're sprinting to finalize v5.1.0 of the SDK and this is taking all our resources (release candidate launched last week mapbox/mapbox-gl-native#9231 🎉 ). Thank you for your patience! |
Hi @zugaldia, |
@bkhezry changes looking great! will work on putting the finishing touches on this so we can get this merged. Great job! Thank you for the contribution. |
…ugins-android into bkhezry-geojson-plugin
@bkhezry things are looking good for a first release, can you resolve the conflicting files? |
# Conflicts: # plugins/app/build.gradle # plugins/app/src/main/AndroidManifest.xml # plugins/app/src/main/res/values/strings.xml # plugins/build.gradle # plugins/settings.gradle
…eojson-plugin # Conflicts: # plugins/app/build.gradle # plugins/app/src/main/AndroidManifest.xml # plugins/build.gradle # plugins/settings.gradle
…eojson-plugin # Conflicts: # plugins/app/build.gradle # plugins/app/src/main/AndroidManifest.xml # plugins/build.gradle # plugins/settings.gradle
Hi @tobrun |
@bkhezry our CI build is failing on checkstyle:
Here is more information how to setup checkstyle cfr Mapbox checkstyle. |
@tobrun checkstyle errors fixed. sorry about that. |
#37
url
,assets
orpath
.OnLoadingGeoJsonListener
for handlepreload
,loaded
andloadFailed
event of GeoJson loading.onMarkerClickListener
for handle marker click event and returnJSONObject
of pointproperties
.