Select to view content in your preferred language

Url Query (urlToObject)

5694
5
Jump to solution
08-22-2014 06:09 AM
JonathanPascoe
Deactivated User

I'm trying to add a urlToObject query on map load so as to pass x/y coordinates to an appbuilder map via url and zoom to location.  Any thoughts on where to insert code block?  This was pretty easy with default JS but my naivety on the builder is making this a bit more complicated than expected.  Widget model was first thought but I didn't see how to bypass adding button to ui while enabling code. Thanks in advance

Tags (2)
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

  So here is what you need to change if you want to specify a center (Lat,Lng) and a zoom scale:

In the ConfigManager.js at line 606 > function _addDefaultMap  (Assuming Beta 2)

Add this to the end of the function:

      if(this.urlParams.center){

        config.map.mapOptions.center = this.urlParams.center;

      }

      if(this.urlParams.scale){

        config.map.mapOptions.scale = this.urlParams.scale;

      }

In the MapManager.js at line 261 > function _processMapOptions

Add this to end of function before return:

        if (ret.center){

          ret.center = ret.center.split(",");

        }

That should be it. This is what the addition to the url would look like:

index.html?center=-84.391136,33.74579,&scale=72224

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

   So are you wanting to set the maps extent in the url, just provide a point to center the map at, or a point to center the map at and a scale to zoom to?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

  So here is what you need to change if you want to specify a center (Lat,Lng) and a zoom scale:

In the ConfigManager.js at line 606 > function _addDefaultMap  (Assuming Beta 2)

Add this to the end of the function:

      if(this.urlParams.center){

        config.map.mapOptions.center = this.urlParams.center;

      }

      if(this.urlParams.scale){

        config.map.mapOptions.scale = this.urlParams.scale;

      }

In the MapManager.js at line 261 > function _processMapOptions

Add this to end of function before return:

        if (ret.center){

          ret.center = ret.center.split(",");

        }

That should be it. This is what the addition to the url would look like:

index.html?center=-84.391136,33.74579,&scale=72224

0 Kudos
JonathanPascoe
Deactivated User

Works like a charm!  Thanks for the help.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

   Glad to help. You have marked my reply as helpful which is great. Marking a reply as helpful will help other user find reply that were helpful yet did not Answer the question. If the reply answered your question than you should click on the "Correct Answer" button (the one with the little green star) on the reply that answered your question, this will help other users find the correct answer.

0 Kudos
JonathanPascoe
Deactivated User

Didn't realize I had to do this from the Content tab to see the additional options.  That code has actually resolved some other rendering options that I had questions about.  So, Thanks again.

0 Kudos