MassGIS / morisoliver

Automatically exported from code.google.com/p/morisoliver
2 stars 2 forks source link

Add ability to have legend for tiled layer (tileset) #229

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 9 years ago
Currently if a layer is added which is type="tiled_overlay" in the folderset, 
no legend is able to be drawn.  Users currently rely on the metadata to see any 
information about the tileset. However, for a simple layer it would be good to 
have a legend.  Can we add an optional hardcoded value legend parameter such as 
legend="http://maps.massgis.state.ma.us/images/moris_noaa_slr_0ft.gif" to the 
folderset to specify a legend image for a layer?  

We have one case where the vector data was very dense (many polygons and many 
vertices) (Sea Level Rise) and did not need to be queried, so creating tilesets 
made the drawing very fast, but as a result we lose the legend.

Original issue reported on code.google.com by Aleda.Fr...@state.ma.us on 17 Sep 2013 at 5:43

MassGIS commented 8 years ago

Aleda 11/12/2015 - would like to discuss possible ways of accomplishing providing a legend image for tiled layers....

cgalvarino commented 8 years ago

snag-0005

cgalvarino commented 8 years ago

@MassGIS, I doubt you have too much control over something like http://maps.massgis.state.ma.us/map_ol/fema_national_flood_hazard_layer_json.txt to add a new attribute to point me to a custom legend. Or do you?

What if you added something new in http://maps.massgis.state.ma.us/temp/oliver_folderset.xml?

Now it is:

<Layer 
  title="FEMA National Flood Hazard Layer" 
  style=""
  name="FEMA_FEMA_National_Flood_Hazard_Layer" 
  type="tiled_overlay" 
  agol="http://maps.massgis.state.ma.us/map_ol/fema_national_flood_hazard_layer_json.txt"
/>

What if we supported an optional legend-ish attrs? E.g.

<Layer 
  title="FEMA National Flood Hazard Layer" 
  style=""
  name="FEMA_FEMA_National_Flood_Hazard_Layer" 
  type="tiled_overlay" 
  agol="http://maps.massgis.state.ma.us/map_ol/fema_national_flood_hazard_layer_json.txt"
  legend_img="http://massgis.maps.arcgis.com/sharing/rest/content/items/8455678914e64b03b565b97d07577279/info/thumbnail/fema_legend_200x133.png",
  legend_href="http://massgis.maps.arcgis.com/home/item.html?id=8455678914e64b03b565b97d07577279"
/>
MassGIS commented 8 years ago

I do have control over those json files. I get them from the service, but I host a copy of them on the maps machine, so I can edit them. That sounds like a good plan.

cgalvarino commented 8 years ago

@MassGIS According to http://resources.arcgis.com/en/help/rest/apiref/mslegend.html, it looks like /legend should do the trick.

Click on the legend link here http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Tapestry/MapServer and you get something.

But click on the legend link in MassGIS land here http://tiles.arcgis.com/tiles/hGdibHYSPO59RG1h/arcgis/rest/services/FEMA_National_Flood_Hazard_Layer/MapServer and you don't get the same kind of thing.

Is that something you can enable? If so I bet I can just follow the bouncing ball w/o any JSON or XML changes.

MassGIS commented 8 years ago

I think you stumbled upon a rare case where we published a vector layer with some dummy polygons just to have a legend. Most layers don't have that parallel mapservice offering the legend. Some raster layers won't be up in ArcGIS Online also. So I think the link to an image I craft and store on the maps.massgis.state.ma.us server is probably best. I should know what width/height would be good to use and I can make a sample one.

cgalvarino commented 8 years ago

You want to pick a test JSON and modify it w/ a new legend img attr?

cgalvarino commented 8 years ago

And if that doesn't work, we'll add it to a folderset.xml.

MassGIS commented 8 years ago

OK will do

MassGIS commented 8 years ago

OK, I made a legend for this layer and stored it at a new "legends" folder on maps: http://maps.massgis.state.ma.us/map_ol/legends/fema_national_flood_hazard_layer_legend.png You'll need to modify your copy of the json? Or should I make a copy of the json file on maps? Why do you need both legend_img and legend_href, wouldn't legend_img be enough?

cgalvarino commented 8 years ago

Since these files, e.g. http://maps.massgis.state.ma.us/map_ol/fema_national_flood_hazard_layer_json.txt, live on your side, could you modify that one?

I was follownig the model in the description:

To display a legend for this layer, add <a href='http://massgis.maps.arcgis.com/home/item.html?id=8455678914e64b03b565b97d07577279' target='_blank'>http://massgis.maps.arcgis.com/home/item.html?id=8455678914e64b03b565b97d07577279</a> to your map along with this service"

If we just need an img, forget about the href.

MassGIS commented 8 years ago

That was a special case... so just stick with the one reference to the image URL and you should be fine.

Warming up to how to test things.. The problem with me modifying http://maps.massgis.state.ma.us/map_ol/fema_national_flood_hazard_layer_json.txt on my side is that is a live file that the live OLIVER is using - there is a reference to it from http://maps.massgis.state.ma.us/temp/oliver_folderset.xml
I think to test things I'm going to make a folder map_ol_2016 with any new OLIVER code, and have that point to a http://maps.massgis.state.ma.us/temp/oliver_folderset_2016.xml and that can point to a http://maps.massgis.state.ma.us/map_ol_2016/fema_national_flood_hazard_layer_json.txt

MassGIS commented 8 years ago

I modified the hosted copy of the JSON for the FEMA tiled service (but my test one): http://maps.massgis.state.ma.us/map_ol_2016/fema_national_flood_hazard_layer_json.txt I added this close to the top of the file:

"legend_img": "http://maps.massgis.state.ma.us/map_ol/legends/fema_national_flood_hazard_layer_legend.png"

MassGIS commented 8 years ago

http://maps.massgis.state.ma.us/map_ol_2016/legends contains all the legends but 1 or 2 that I'll need.

MassGIS commented 8 years ago

I've asked Michael Trust to help make one for elevation, and to consider if he wants one for Detailed Features. Otherwise, here is the list: tiled_layer_legends

MassGIS commented 8 years ago

I modified the json files in map_ol_2016 as well:

http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_combined_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_0_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_1_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_2_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_3_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_4_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_5_ft_json.txt http://maps.massgis.state.ma.us/map_ol_2016/czm_noaa_slr_6_ft_json.txt

cgalvarino commented 8 years ago

Thanks, this looks great. I'll see what kind of trouble I can get into down here.

MassGIS commented 8 years ago

The legend pngs are not a standard width, but I could make them that way if you want me to.

cgalvarino commented 8 years ago

This looks like progress to me. It involved a few minor changes here in OLIVER and a lot of digging into the underlying GoeExt (ancient!) code. I need to figure out a good way to roll GeoExt into this repo.

Map snag-0043

Printout snag-0042

MassGIS commented 8 years ago

This looks great!

MassGIS commented 8 years ago

4/26 Aleda tested in http://maps.massgis.state.ma.us/map_ol_2016/oliver.php Seems to work. Other OLIVER functionality seems OK. Aleda will ask Emily to test and also try to add another legend to another layer.

MassGIS commented 8 years ago

I also got it to work with Hurricane Surge Inundation Zones. I have a few more layers I can set up now...