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

Support custom CRS #529

Merged
merged 11 commits into from
Mar 2, 2020
Merged

Support custom CRS #529

merged 11 commits into from
Mar 2, 2020

Conversation

maRci002
Copy link
Contributor

Hello guys, me and @fegyi001 made avaible to use custom CRS in this project with help of proj4dart project (we are the authors of it).

Proj4Crs and Proj4Projection classes based on Proj4Leaflet project and it has BSD 2-Clause "Simplified" License so we need to make sure we can use their codebase.

We also added some support for multiple origins based on this commit (which is still not reviewed but I tested this feature on this map and the map isn't bouncing unlike in Leaflet's map 👌).

We made an example page which uses EPSG:3413 crs.
map_custom_crs

Closes #514

@maRci002
Copy link
Contributor Author

The only problem occurs if you try to over zoom / over unzoom, but the app doesn't crash or there isn't any flutter red error screen, just your console is being flooded 😄

You cannot over zoom via double taps only with double finger scale. I think this problem shouldn't be fixed on this level because I assume num scale(double zoom) { will have max value based on maxZoom and at least 0 value.

Over unzoom:

════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
The following RangeError was thrown while handling a gesture:
RangeError (index): Invalid value: Not in range 0..8, inclusive: -1

When the exception was thrown, this was the stack: 
#0      List.[] (dart:core-patch/array.dart:15:52)
#1      Proj4Crs.scale (package:flutter_map/src/geo/crs/crs.dart:293:30)
#2      Proj4Crs.pointToLatLng (package:flutter_map/src/geo/crs/crs.dart:258:22)
#3      MapState.unproject (package:flutter_map/src/map/map.dart:238:24)
#4      MapGestureMixin.handleScaleUpdate.<anonymous closure> (package:flutter_map/src/gestures/gestures.dart:73:29)
...
Handler: "onUpdate"
Recognizer: ScaleGestureRecognizer#3b3f6
  debugOwner: GestureDetector
════════════════════════════════════════════════════════════════════════════════════════════════════

Over zoom:

════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
The following RangeError was thrown while handling a gesture:
RangeError (index): Invalid value: Not in range 0..8, inclusive: 9

When the exception was thrown, this was the stack: 
#0      List.[] (dart:core-patch/array.dart:15:52)
#1      Proj4Crs.scale (package:flutter_map/src/geo/crs/crs.dart:294:30)
#2      Proj4Crs.pointToLatLng (package:flutter_map/src/geo/crs/crs.dart:258:22)
#3      MapState.unproject (package:flutter_map/src/map/map.dart:238:24)
#4      MapGestureMixin.handleScaleUpdate.<anonymous closure> (package:flutter_map/src/gestures/gestures.dart:73:29)
...
Handler: "onUpdate"
Recognizer: ScaleGestureRecognizer#40141
  debugOwner: GestureDetector
════════════════════════════════════════════════════════════════════════════════════════════════════

@johnpryan
Copy link
Collaborator

This looks good to me, ready to merge?

@maRci002
Copy link
Contributor Author

maRci002 commented Feb 28, 2020

Yes 😃

Just take a test ride with mentioned review and use zoom / scalelayer plugins.

Edit:

  ScaleLayerPluginOption(
	lineColor: Colors.blue,
	lineWidth: 2,
	textStyle: TextStyle(color: Colors.blue, fontSize: 12),
	padding: EdgeInsets.all(10),
  ),
  ZoomButtonsPluginOption(
	minZoom: 1,
	maxZoom: maxZoom.toInt(), // Don't forget to adjust maxZoom
	mini: true,
	padding: 10,
	alignment: Alignment.bottomRight,
  ),

And go to zoombuttons_plugin_option.dart
And change line 65:
From:
zoom = zoomButtonsOpts.minZoom as double;
To:
zoom = zoomButtonsOpts.minZoom.toDouble();

Sometimes as double throws exception even at ZoomButtonsPlugins page:
type 'int' is not a subtype of type 'double' in type cast

@maRci002
Copy link
Contributor Author

Forget about zoom problems this PR resolves another problem. So yes I am ready to merge.

@johnpryan johnpryan merged commit aeedf9c into fleaflet:master Mar 2, 2020
@maRci002 maRci002 mentioned this pull request Mar 6, 2020
@maRci002 maRci002 deleted the support_custom_crs branch March 6, 2020 20:36
ziuyung pushed a commit to SXTSOFT/flutter_map that referenced this pull request Mar 27, 2020
* master: (73 commits)
  去掉不要的
  Update CHANGELOG.md (fleaflet#511)
  Proj4dart update (fleaflet#541)
  Support custom CRS (fleaflet#529)
  docs(readme): add details about open street map provider (fleaflet#495)
  Wms support. (fleaflet#500)
  0.8.2 release
  polyline with gradient (fleaflet#452)
  clean up from fleaflet#487
  0.8.1 release
  Zoombutton plugin (fleaflet#487)
  dartfmt
  0.8.0 release (Flutter 1.12)
  Use Wrap for marker_anchor sample
  Polygon culling (fleaflet#449)
  Tidyup (fleaflet#469)
  Update build files from fleaflet#478
  upgrade flutter version, support Flutter 1.12
  Update README.md (fleaflet#465)
  add opacity option to tile layers (fleaflet#453)
  ...

# Conflicts:
#	example/android/app/build.gradle
#	example/android/app/src/debug/AndroidManifest.xml
#	example/android/app/src/main/AndroidManifest.xml
#	example/android/app/src/profile/AndroidManifest.xml
#	example/android/build.gradle
#	example/android/gradle.properties
#	example/ios/Runner.xcodeproj/project.pbxproj
#	example/lib/pages/home.dart
#	example/web/index.html
#	lib/flutter_map.dart
#	lib/src/geo/crs/crs.dart
#	lib/src/layer/overlay_image_layer.dart
#	lib/src/layer/tile_layer.dart
#	lib/src/layer/tile_provider/mbtiles_image_provider.dart
#	lib/src/map/flutter_map_state.dart
#	pubspec.yaml
@savasadar
Copy link

Hello @maRci002, I am living a problem about the create a new projection with yandex map tiles.
Could you help?
#642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom CRS/SRS (feature request)
3 participants