Polyline.setPoints() method not working and/or crashing the app in ios11
See original GitHub issueI’m submitting a … (check one with “x”) [ ] question [x] any problem or bug report [ ] feature request
The plugin version: (check one with “x”) [ ] 2.0-beta3 (github) [x] 2.0 (npm)
If you choose ‘problem or bug report’, please select OS: (check one with “x”) [ ] Android [x] iOS
cordova information: (run $> cordova plugin list
)
code-push 2.0.2-beta "CodePushAcquisition"
com.googlemaps.ios 2.4.0 "Google Maps SDK for iOS"
cordova-background-geolocation-lt 2.8.5 "BackgroundGeolocation"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-background-fetch 5.1.1 "CDVBackgroundFetch"
cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack"
cordova-plugin-code-push 1.9.8-beta "CodePush"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-googlemaps 2.0.11 "cordova-plugin-googlemaps"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
parse-push-plugin 1.0.7 "ParsePushPlugin"
If you use @ionic-native/google-maps
, please show me the package.json
Current behavior:
There is an issue with adding and setting polyLines: Setting polylines either does not work or crashes the app.
Expected behavior:
Expected behavior is for the polyline to plot to the map as line.setPoints( <array> )
is updated.
Steps to reproduce:
The issue revolves around setting points for a polyline. When I add an array of poinsts, ie: [{"lat":123, "lng":456}]
it won’t update the polyline, and in some cases it crashes the app.
// This is after initiating the map
// var map = plugin.google.maps.Map.getMap(mapDiv, {...});
// map.on(plugin.google.maps.event.MAP_READY, initMap) ...
var line = false;
map.addPolyline({
'points': [],
'color': '#5f85ff',
'width': 8,
'zIndex': 5
}, function(polyline) {
line = polyline;
});
function addToPolyline(arr) {
arr = arr || []; //[{"lat":123, "lng":456}]
if (arr.length > 0 && line && typeof line.setPoints !== "undefined") {
line.setPoints(arr);
}
}
// When new data points come in...
addToPolyline(arr);
Screen capture or video record:
Related code, data or error log (please format your code or data):
These are the logs in xCode when it crashes:
2017-10-05 15:23:19.295713-0700 Barkly[5962:13262301] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: mutablePath)'
*** First throw call stack:
(
0 CoreFoundation 0x000000011077c03b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010d825f41 objc_exception_throw + 48
2 CoreFoundation 0x00000001107bbe2c _CFThrowFormattedException + 194
3 CoreFoundation 0x00000001106907ca -[__NSDictionaryM setObject:forKey:] + 986
4 Barkly 0x00000001096b6dc1 __28-[PluginPolyline setPoints:]_block_invoke + 1057
5 Foundation 0x000000010d23c9b7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
6 Foundation 0x000000010d23c81a -[NSBlockOperation main] + 68
7 Foundation 0x000000010d23acd6 -[__NSOperationInternal _start:] + 778
8 libdispatch.dylib 0x000000010e3be43c _dispatch_client_callout + 8
9 libdispatch.dylib 0x000000010e3c3af4 _dispatch_block_invoke_direct + 592
10 libdispatch.dylib 0x000000010e3be43c _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000010e3c3af4 _dispatch_block_invoke_direct + 592
12 libdispatch.dylib 0x000000010e3c3884 dispatch_block_perform + 109
13 Foundation 0x000000010d236ce4 __NSOQSchedule_f + 342
14 libdispatch.dylib 0x000000010e3be43c _dispatch_client_callout + 8
15 libdispatch.dylib 0x000000010e3c4856 _dispatch_continuation_pop + 967
16 libdispatch.dylib 0x000000010e3c2c86 _dispatch_async_redirect_invoke + 780
17 libdispatch.dylib 0x000000010e3ca1f9 _dispatch_root_queue_drain + 772
18 libdispatch.dylib 0x000000010e3c9e97 _dispatch_worker_thread3 + 132
19 li2017-10-05 15:23:19.295727-0700 Barkly[5962:13261867] {}
2017-10-05 15:23:19.295713-0700 Barkly[5962:13262828] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: mutablePath)'
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
Yes.
I pass it at first to establish the “line” (polyline) reference, so that I can call
line.setPoints(arr)
in the future without needing to callmap.addPolyline
. I suppose I should just wait until there are 2 or more points, then create the polyline. However, what if I want to reset the polyline back to empty?Should I use polyline.remove() and then wait until I have 2 or more points again and add another polyline or update the existing one?
In my code, I use the same polyline on the same map. Sometimes I need to reset the polyline, so polyline.setPoints([]) seemed like the most intuitive thing to do and it worked in older versions of the plugin.
At any rate, I appreciate you maintaining this plugin. In my code I’ll wait until I have 2+ points to create the polyline and then just remove it if I need to reset - if that’s the way it was intended to work.