SVG4601: SVG Path data has incorrect format and could not be completely parsed.

4341
1
Jump to solution
01-19-2016 09:02 AM
TyroneBiggums
Occasional Contributor III

I have a custom draw tool. The user can draw selected graphics on the map and edit them with the edit toolbar, or via a control panel with the graphic coordinates listed for edit.

For instance, the user can draw a polygon with 4 sides on the map and select to edit that graphic. The edit toolbar becomes activated, and a list textboxes showing 4 coordinates are displayed.

The user can move vertices or the graphic itself, and add points. If the edit toolbar is used to edit the shape, the coordinate list is updated. And, of course, if the coordinate list is updated, the graphic is also updated. What I do is create a new Esri Polygon object with the updated set of coordinates for the graphic and call setGeometry, passing the new Polygon.

If the user updates one of the coordinates via textbox, then moves the graphic with the toolbar, the graphic disappears. The points remain visible only through the edit toolbar remaining active. The coordinate that was modified is now NaN so the polygon is not completed.

In developer tools, a lot of interesting stuff happens that I don't understand. I set a breakpoint in the 'graphic-move-start' event and in the 'graphic-move-stop' event. Here is what I found...

1. Most importantly, the polygon's rings[0] for that graphic have coordinates appended at the end. Example below:

     The user modified the 2nd point.

     On graphic-move-start: map.getLayer('GraphicCollection').graphics[0].geometry.rings[0][1]

        0 "-2010708.3024555703"

        1 "6613938.375964609"

     On graphic-move-stop: map.getLayer('GraphicCollection').graphics[0].geometry.rings[0][1]

        0 "-2010708.3024555703704443.6526759975"

        1 "6613938.375964609332653.94709699973" (Note the double decimal. A new coordinate is appended at the end. And, if the coordinate was moved to the right place, it would also have the '-', like in "6613938.375964-609332653.94709699973"

2. I get the error from the subject line: SVG4601: SVG Path data has incorrect format and could not be completely parsed. Why?

3. I added one graphic with 4 sides to an otherwise empty blank basemap. Why would the map.graphics.graphics count be 12? I do have code that highlights each editable point, but I can't account for 12 graphics. Why are there 12?

4. Of the 12 graphics listed, after graphic-move-stop, a lot of them are points that have an x and y of NaN. Why?

Note: No other code runs between graphic-move-start and graphic-move-stop events. In fact, I can remove the events completely and the bug remains. I just wanted to point out that the graphic rings are as expected after the graphic-move-start and become screwed up by the time graphic-move-stop would fire.

My thought is that map.graphics.graphics collection does not get updated properly when I setGeometry of my map.getLayer('name').graphics. Are they out of sync to where I see the results that I see?

Thanks!

p.s. This is for 3.14

EDIT: I noticed that if I use the edit toolbar to move a vertice or change the scale of the graphic before I move the graphic, the above bug doesn't occur. I can move the graphic with the edit toolbar, with no problems unless I change the coordinates via textbox first. So the work around steps are, draw a graphic, edit a graphic with textboxes, change the scale, then I can move the graphic. Of course, this isn't helpful for my code, but thought it might be helpful in debugging?

0 Kudos
1 Solution

Accepted Solutions
TyroneBiggums
Occasional Contributor III

Solved: If someone comes across this issue, make sure the values that come back from any conversions, mercators, etc spit out parseFloat values. My rings[0] had string values in it. That threw everything off.

I figured I'd embarrassingly leave this here in case someone else has my same struggles.

We also figured out why the map.graphics.graphics collection is so high. Each little icon for the edit toolbar is a shape. Those graphics are NaN b/c the rings with strings in it has a domino affect.

View solution in original post

1 Reply
TyroneBiggums
Occasional Contributor III

Solved: If someone comes across this issue, make sure the values that come back from any conversions, mercators, etc spit out parseFloat values. My rings[0] had string values in it. That threw everything off.

I figured I'd embarrassingly leave this here in case someone else has my same struggles.

We also figured out why the map.graphics.graphics collection is so high. Each little icon for the edit toolbar is a shape. Those graphics are NaN b/c the rings with strings in it has a domino affect.