Giter Club home page Giter Club logo

Comments (5)

artsmax avatar artsmax commented on August 26, 2024 1

thank you for your reply. In the end I want to update a webmap based on a json file, so saving it as a new one doesnt do the trick in my case. I'm looking forward to your workflow!

from arcgis-python-api.

nanaeaubry avatar nanaeaubry commented on August 26, 2024

@artsmax
There is no key "text" in the item properties that allows you to do this. I will try to find you a workflow and post it here.

But if you are simply trying to copy webmap1 into a new webmap then you can simply save() which will create a new webmap item and not update the original.

from arcgis-python-api.

artsmax avatar artsmax commented on August 26, 2024

@nanaeaubry , I would still like to see your workflow:) Are you able/willing to share? regards, Max

from arcgis-python-api.

nanaeaubry avatar nanaeaubry commented on August 26, 2024

@artsmax
Thanks for being patient! I got the update to work but have a few caviats to make you aware of as well.

Here is the code:

from arcgis.gis import GIS
from arcgis.mapping import WebMap
import json
gis = GIS(profile="your_online_profile")

# Get the two webmap items we want to use
item1 = gis.content.get("fa14b6470a8845aca963051e57c2f4bb")
item2 = gis.content.get("6093ff378f2546bea2159ab7beae0569")


# Use the data from symbol_webmap to update the basic_webmap
data = item2.get_data()
item1.update({"text":json.dumps(data)})
item1

You were on the right track to use the json data of the item and pass as text. However, the update should be done on the Item class and not the WebMap class. In the Item class we accept 'text' as a key in the item_properties dictionary.

This will work BUT it depends on your use case. I tested this where I had a feature layer in two different webmaps. In one webmap I left it as-is and in another I updated the symbology and saved it. Then when I did the update above the basic webmap got updated with the cool symbology.
This will work if you have the same feature layers in your webmap. This will not work if you have different feature layers and you want to apply the symbology of one layer to a totally different layer.
The reason is that the underlying structures are dictionaries. So this is a dictionary updating another dictionary and the rules for that apply. You might have to do a bit of manual search and replace if you want to apply to more complicated use cases.

Hope this helps jump start what you are trying to do! :) Good luck!

from arcgis-python-api.

artsmax avatar artsmax commented on August 26, 2024

thank you very much! Exactly what I was looking for:)

from arcgis-python-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.