mapandcenter zoom to the wrong location

2936
1
Jump to solution
11-15-2015 04:33 PM
LefterisKoumis
Regular Contributor

I have this script that defines a point, it draws the point at the correct location but it centers the map at the wrong place! Why?

Thanks.

startup: function() {

      this.inherited(arguments);

    

  pointSymbol = new SimpleMarkerSymbol(

  SimpleMarkerSymbol.STYLE_CIRCLE, 10,

  new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 1),

  new Color([0, 204, 0])

  );

  myGraphicPoint = new Point([-121.07462622, 38.90015662]);

  myGraphicMarker = new Graphic(myGraphicPoint, pointSymbol);

  myGraphicMarker.setAttributes({"name":"Project Spot"});

  myGraphicsLayer = new GraphicsLayer();

  myGraphicsLayer.add(myGraphicMarker);

  this.map.addLayer(myGraphicsLayer);

      this.map.centerAndZoom(myGraphicPoint.geometry, 8);

    },

0 Kudos
1 Solution

Accepted Solutions
OwenEarley
Regular Contributor

Try changing this line:   

this.map.centerAndZoom(myGraphicPoint.geometry, 8);

to:

this.map.centerAndZoom(myGraphicPoint, 8);

The Center and Zoom function takes a Point as the first argument.

View solution in original post

1 Reply
OwenEarley
Regular Contributor

Try changing this line:   

this.map.centerAndZoom(myGraphicPoint.geometry, 8);

to:

this.map.centerAndZoom(myGraphicPoint, 8);

The Center and Zoom function takes a Point as the first argument.