Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Smart Mapping Tools in ArcGIS API for JavaScript
Rene Rubalcava
Rene Rubalcava

Posted on • Originally published atodoe.net

     

Smart Mapping Tools in ArcGIS API for JavaScript

Smart Mapping Tools

Smart Mapping is an Esri wide tool of the platform. It provides some intuitive ways for you create awesome visualizations for your web mapping apps. I highly recommend that your first stop in your Smart Mapping journey begin in theMap Viewer. When you style your layers, and maps in the Map Viewer, you can save them, and then easily consume them, styles and all, in your own applications.

However, you might have to customize some things once in a while. You may be working with CSV, GeoJSON, of unknown various data sources that you want to display in your app. That's where the Smart Mapping toolsin the ArcGIS API for JavaScript can be useful.

I did a couple of videos on how you cancreate popups from the layer, and also use theSmart Mapping popup helpers to create popups to go along with your visualization.

However, you can also use various modules together to help you make awesome apps!

  • Min/Max Scale
  • PopupTemplate
  • Renderer

One of the first things you can do is let the Smart Mapping tools help you determine optimalscale ranges for your layers.

importscaleRangefrom'@arcgis/core/smartMapping/heuristics/scaleRange';// determine min/max scalesconst{minScale,maxScale}=awaitscaleRange({layer:featureLayer,view,});// apply scales to layerfeatureLayer.minScale=minScale;featureLayer.maxScale=maxScale;
Enter fullscreen modeExit fullscreen mode

ThescaleRange method needs the target layer, and the view to determine proper scale ranges. It doesn't always make sense to see data drawn at all scales, so this could be very useful to have a clean mapping experience in your application.

Next we can create a renderer for our layer. In this case, we might be interested in creating arelationship renderer.

import{createRenderer}from'@arcgis/core/smartMapping/renderers/relationship';const{renderer}=awaitcreateRenderer({layer:featureLayer,view,field1:{field:'HSE_UNITS',},field2:{field:'VACANT',},});featureLayer.renderer=renderer;
Enter fullscreen modeExit fullscreen mode

Per thedocumentation we need to provide the two fields we are interested in visualizing the relationship of. Then we can assign the returned renderer to the layer.

Then finally, we went through all the trouble to determine a good scale and a captivating visualization, we should compliment that with a proper popup!

import{getTemplates}from'@arcgis/core/smartMapping/popup/templates';const{primaryTemplate}=awaitgetTemplates({layer:featureLayer,});featureLayer.popupTemplate=primaryTemplate.value;featureLayer.popupTemplate.title=primaryTemplate.title;
Enter fullscreen modeExit fullscreen mode

Thetemplates helper will determine the best format of the popup based on the renderer being used. This is super useful so you can move away from plain table based popups when trying to convey information in your applications!

And there you go! That's a basic, yet effective workflow to help you automate the use of Smart Mapping in your own applications. I look forward to seeing some awesome visualizations in all your mapping apps!

You can see more in the video below!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Blogger, author, youtuber, webdev, geodev
  • Location
    Redlands, CA
  • Work
    Principal SoftWhere Engineer at Esri
  • Joined

More fromRene Rubalcava

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp