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

Fix null when region null #347

Open
wants to merge 5 commits into
base: Development
Choose a base branch
from

Conversation

dothanhbinh41
Copy link

@dothanhbinh41 dothanhbinh41 commented Aug 16, 2018

  • When MapRegion is null, would throw an exception in Method "UpdateMapRegion()"

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Xamarin.Build.Download.0.4.11\build\Xamarin.Build.Download.props" Condition="Exists('..\..\..\packages\Xamarin.Build.Download.0.4.11\build\Xamarin.Build.Download.props')" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this upgrade necessary to solve the null issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok man, i will rollback to old package! but i think package too old, we should update them 👍

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="15" />
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="27" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to do without the target SDK version

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

say ok! i agree

@@ -17,6 +17,14 @@ public MapSpan(Position center, double latitudeDegrees, double longitudeDegrees)
LongitudeDegrees = Math.Min(Math.Max(longitudeDegrees, MinimumRangeDegrees), 180.0);
}

public MapSpan(Position ne, Position sw)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be best as a separate proposal. I've thought about having this same thing before and I think there are potential pitfalls with it.

Copy link
Author

@dothanhbinh41 dothanhbinh41 Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why native code Region/Span been limit by some point but in TK Region/Span been limit by Center and Radius. What difference with Region and Map Center + Zoom Level ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue is that it's really easy to pass in parameters that won't behave as you would want.

  1. how does it behave if the distance between N + S is 200 Meters and the distance between E + W is 200 Kilometers?

  2. how does it behave if someone passes in nw + se by accident?

Essentially if you pick a single point and then a radius, it'll be far less prone to error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • NS EW or Radius Center ... i think they are not different, they are in a rectangle.
    untitled

Copy link
Collaborator

@ChaseFlorell ChaseFlorell Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plug this in and tell me what happens

// this IS a valid rectangle that fits the scenario above
var ne = new Position {
    Latitude = 47.34,
    Longitude = -88.97
};
var sw = new Position {
    Latitude = 47.33,
    Longitude = -121.31
};
// this is an INVALID rectangle based on the scenario above
var ne = new Position {
    Latitude = 47.33,
    Longitude = -88.97
};
var sw = new Position {
    Latitude = 47.34,
    Longitude = -121.31

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your example like Center and Radius = 0 or radius so tiny

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, but as a user I might expect it to round up to the radius of East/West. The point is that the behavior is subject interpretation. With Center/Radius there's no subjectivity.

<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Xamarin.Forms" Version="2.5.0.91635" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Xamarin.Forms" Version="3.2.0.729530-pre2" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely don't want to be depending on a pre-release version here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am restoring them :D

@ChaseFlorell
Copy link
Collaborator

overall I'm seeing a number of changes here that while value added, they're beyond the scope of the bug. Are you able to PR the bug fix here and open an issue regarding the dependency updates?

@dothanhbinh41
Copy link
Author

when call method UpdateMapRegion() in TKCustomMapRenderer (android),
if MapRegion is null , exception will throw here

if (!FormsMap.MapRegion.Equals(GetCurrentMapRegion(_googleMap.CameraPosition.Target)))
 {
    MoveToMapRegion(FormsMap.MapRegion, FormsMap.IsRegionChangeAnimated);
 }

FormsMap.MapRegion.Equals(

We should check null it and this way by me

if (FormsMap.MapRegion?.Equals(GetCurrentMapRegion(_googleMap.CameraPosition.Target)) == false)
{
     MoveToMapRegion(FormsMap.MapRegion, FormsMap.IsRegionChangeAnimated);
}

@ChaseFlorell
Copy link
Collaborator

Did you Rebase off of master? there was a closed PR earlier with a similar solution.
#335

@dothanhbinh41
Copy link
Author

Could you close this PR, i would create new PR :D that's the simplest way

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.

3 participants