1

I am using Arcgis Javascript API for my map and the map is coming from Arcgis online usng map by ID.

Here is code

         var startExtent = new esri.geometry.Extent(52.37615, 13.11937,52.64877,13.65801,
                  new SpatialReference({wkid:4326}) );

                  var createMapOptions = {
                mapOptions: {
                    extent : startExtent
                },
               };
              arcgisUtils.createMap("c997ee65fad94ce4ae3c3d9618212099","map",createMapOptions).then(function(response){
                 map = response.map;
              }}
             }) 

I want to set map extent according to Berlin city But it is not working for above extent value and SpatialReference:4326.

But when I used this extent xmin=1231772.125133422&ymin=6464953.10035588&xmax=1843268.35141480187&ymax=7103966.656819923 with SpatialReference:102100 ,It wokrs for me.

I don't know why it not working with SpatialReference:4326.

Does Somebody know Why my code is not working for SpatialReference:4326 and its extent.

I want set map extent according 4326 as shown in code.

  • 1
    But it is not working for above extent value and SpatialReference:4326. - what does that mean? What is happening when you execute your code? What does the javascript console show? – til_b Sep 30 '14 at 8:04
  • If one of these answers, solves your problem, please check the box under that answer. – jbchurchill Oct 1 '14 at 19:41
2

I think you have your terms mixed up.

Map extent is the min X, max X, min Y, max Y coordiates. What you're looking to do is change the SRS (spatial reference system); which you cannot do in a web map, as all that I know use a WGS84 Web Mercator, which is the SRS - 102100.

It looks like the two will use different coordinate values to represent the same area, so you will need to identify where Berlin is within the web mercator format; which will use coordinates similar to -7.09,49.69

2

The general approach would be:

  1. Take coordinates in any spatial reference system
  2. Convert those to the SRS used by the web map using a function provided by the Web Mapping API
  3. Use the converted coordinates to perform actions on your Web Map.

For step 2 maybe you can look at the code from https://developers.arcgis.com/javascript/jssamples/util_coordinate_converter.html and adapt it to your needs?

2

The API page says the extent is set up like this (note the correct order)

new Extent(xmin, ymin, xmax, ymax, spatialReference). You have the correct coordinates but you have x and y confused. Try this instead.

 var startExtent = new esri.geometry.Extent(13.11937, 52.37615, 13.65801, 52.64877,
                  new SpatialReference({wkid:4326}) );

I pasted your coordinates into Google Maps and they work (to represent an extent around Berlin) because Google Maps puts Y before X so (52.37615, 13.11937) is the lower left and (52.64877, 13.65801) is the upper right. You need to put X before Y.

1

as per the API reference, the coordinate system of your extent and ArcGISTiledMapService layer need to match.

https://developers.arcgis.com/javascript/jsapi/map-amd.html#map1 "The tiling scheme of an ArcGISTiledMapServiceLayer must match the projection of the map."

no problem though. you can use webMercatorUtils.geographictowebmercator(latLngExtent) if you'd like to convert your extent to web mercator on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.