a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Apache License 2.0
130 stars 66 forks source link

Unable to use the containsLocation method from the Geometry library. #86

Closed ReddingHomeLoans-admin closed 4 years ago

ReddingHomeLoans-admin commented 4 years ago

I tried first in my angular dart project then again with just the provided examples in a basic web application both return the same error. Stating that containsLocation can't be accessed using static access.

https://dart.dev/tools/diagnostic-messages#static_access_to_instance_member

packages/angular_property_search/src/map_panel/map_panel_component.dart:127:21: Error: Method not found: 'Poly.containsLocation'. var bool = Poly.containsLocation(location, countyLine); ^^^^^^^^^^^^^^^^ When I try to make the method static the following error is returned.

[SEVERE]build_web_compilers:ddc on package:google_maps/google_maps_geometry.ddc.module (cached): Error compiling dartdevc module:google_maps|lib/google_maps_geometry.ddc.js

packages/google_maps/src/google_maps_src_geometry.g.dart:40:18: Error: Expected identifier, but got 'this'. asJsObject(this).callMethod('containsLocation', ^^^^

a14n commented 4 years ago

You have to use poly.containsLocation(location, countyLine);.

Don't forget to load the geometry library as mentionned in https://github.com/a14n/dart-google-maps#coverage

ReddingHomeLoans-admin commented 4 years ago

Thanks! I appreciate the help. I am rather new to dart. Should I have been able to infer poly should be lowercase some how? I would never have guessed that was the issue.

a14n commented 4 years ago

The google maps API is not exactly the same as the API provided by this google_maps package. Particularly for JS namespaces that I had mapped to top level variable. This poly Dart variable is the equivalent of google.maps.geometry.poly JS namespace.