Adding a point & change extent = "Arg: Illegal input string in Vector2D"

1820
9
01-17-2011 06:55 AM
MartenLiebster
New Contributor II
I have map displayed on my page. I have js function that adds another point and moves the extent.

If I do either action independently, it works just fine. But if I add a point and change the extent in the same method:
- the point doesn't show
- when I drag the mouse, I get the "Arg: Illegal input string in Vector2D" error.

I've made sure to use the same spatialReference throughout, as that's the only thing researching the error yields (projection issues).

The code (1) clears existing points, (2) adds the new point (using the map's spatialReference), (3) adds to the existing graphics layer, (4) and then centers the map around the new point.

function moveHomePoint(lon, lat) {
    homeLayer.clear();
    homePT = new esri.geometry.Point(lon, lat, homeMap.spatialReference);
    var homeG = new esri.Graphic(homePT, hSms, attr, infoTemplate);
    homeLayer.add(homeG);

    var homeExtent = new esri.geometry.Extent(
    {
        "ymin": lat - 0.0025,
        "xmin": lon - 0.0025,
        "ymax": lat + 0.0025,
        "xmax": lon + 0.0025,
        "spatialReference": { "wkid": 4326 }
    });
    homeMap.setExtent(homeExtent);
}


Again if I comment out the layer.add line, the extent is set fine. If I comment out the setExtent line, the point shows up - though I have to zoom/pan to get to it if it's not in the current extent.

I've tried to add the point with a JSON type spatialReference as well, with the same result.



Thanks in advance for any help!
0 Kudos
9 Replies
MartenLiebster
New Contributor II
I just tried this with the same result (map moves, but no point, if you pan then you get the error)

function moveHomePoint(lon, lat) {
    homeLayer.clear();
    homePT = new esri.geometry.Point(lon, lat, homeMap.spatialReference);
    var homeG = new esri.Graphic(homePT, hSms, attr, infoTemplate);
    homeLayer.add(homeG);

    homeMap.centerAt(homePT);
}


Again, if I comment out the centerAt, the point shows up, but you have to manually move to it, if it's not in the current extent.

Thanks again
0 Kudos
MartenLiebster
New Contributor II
One more attempt with the same result.

(Tried to add it to the map's graphics collection instead of a layer)

function moveHomePoint(lon, lat) {
    homeLayer.clear();
    homePT = new esri.geometry.Point(lon, lat, homeMap.spatialReference);
    var homeG = new esri.Graphic(homePT, hSms, attr, infoTemplate);  

    homeMap.graphics.add(homeG);
    homeMap.centerAt(homePT);
}
0 Kudos
MartenLiebster
New Contributor II
More strangeness ...

My map, when the page starts up, had a point in Florida. With a button click, I remove the point and another one in the same general area (but not in the current Extent) and did a centerAt(). It worked as expected - map moved and my graphic was there.

When I had the button click change to a point in New York City, then map moved and point didn't show, and when panning I the got the error.

Again, if I take the centerAt() out with the NYC point, then the graphic shows up just fine - you just have to move the map manually.
0 Kudos
MartenLiebster
New Contributor II
Anyone have an idea?
0 Kudos
MartenLiebster
New Contributor II
I'm still stuck on this ... am I missing a step?

It works fine sometimes, other times I get the strange error message.

Thanks
0 Kudos
MartenLiebster
New Contributor II
Am I the only one getting this error?

Any one have an idea of how to debug this?

Thanks!!!
0 Kudos
MartenLiebster
New Contributor II
Perhaps I am going about his wrong ...

Obviously I am doing something wrong and unique. The only search results about this are people who are mixing different SpatialReference values - but I am keeping them the same throughout. Plus when I set the new extent the map is showing the right area.

Are there any examples about removing existing graphics, setting a new extent and add a new graphic - via javascript?
0 Kudos
AaronConnolly
Occasional Contributor
Perhaps I am going about his wrong ...

Obviously I am doing something wrong and unique. The only search results about this are people who are mixing different SpatialReference values - but I am keeping them the same throughout. Plus when I set the new extent the map is showing the right area.

Are there any examples about removing existing graphics, setting a new extent and add a new graphic - via javascript?


I'm getting a similar error when adding graphics and changing the map's extent. However I only see the issue in IE8. I'm using version 2.5 of the SDK. The error looks to be coming from the DOJO toolkit.

Were you able to make any headway on this issue?
0 Kudos
JanTunger
New Contributor
Hi
I created a JavaScript map application with a zoom and highlight function and get the same error in IE too. The highlight function adds an marker to the map on the new center point. Both function become executed at the same time. I have noticed that the error comes only if the map is large and if the bounding box around the center is to close. If I add enough space to the center coordinate to zoom to the second LOD of my cached service it works fine.
Anyone have an idea or bug fix?

Thanks
0 Kudos