<?xml version="1.0"?>
<mapbook version="3.0">
	<!--
		The mapping services define the source of the mapping data.
	-->
  
    <map-source name="sketch" type="vector" title="Drawing and Markup">
        <layer name="default" selectable="true" status="on">
            <style><![CDATA[
            {
                "circle-radius": ["coalesce", ["get", "style:stroke-width"], 4],
                "circle-color": ["coalesce", ["get", "style:fill-color"], "#fec44f"],
                "circle-stroke-color": ["coalesce", ["get", "style:stroke-color"], "#d95f0e"],
                "fill-color": ["coalesce", ["get", "style:fill-color"], "#fec44f"],
                "fill-opacity": ["coalesce", ["get", "style:fill-opacity"], 0.6],
                "line-color": ["coalesce", ["get", "style:stroke-color"], "#d95f0e"],
                "line-opacity": ["coalesce", ["get", "style:stroke-opacity"], 0.8],
                "line-width": ["coalesce", ["get", "style:stroke-width"], 4],
                "text-field": "{label}",
                "text-color": ["coalesce", ["get", "style:label-color"], "#333333"],
                "text-size": ["coalesce", ["get", "style:label-size"], 16]
            }
            ]]></style>

            <legend type="html"><![CDATA[
            The <b>Drawing and Markup</b> layer can be used to add user defined shapes
            to the map.<br>
            <div style='padding-top: 3px; padding-bottom: 5px;'>
                <div style='vertical-align: middle; display: inline-block; width: 2em; height: 1em; background-color: #fec44f; border: solid 2px #d95f0e;'></div>
                <b>Drawing</b>
            </div>
            ]]></legend>

            <template name="identify" auto="true" />
        </layer>

        <properties>
            <property name="label" label="Sketch label" />

            <property name="style:label-color"
                label="Label color" type="color" default="#333333" />

            <property name="style:label-size"
                label="Label size" type="number" default="16" />

            <property name="style:stroke-color"
                label="Stroke color" type="color" default="#d95f0e" />

            <property name="style:stroke-width"
                label="Stroke size" type="range" min="0" max="10" default="4" />

            <property name="style:stroke-opacity"
                label="Stroke opacity" type="range"
                min="0" max="1" step="0.1" default="0.8" />

            <property name="style:fill-color"
                label="Fill color" type="color" default="#d95f0e" />

            <property name="style:fill-opacity"
                label="Fill opacity" type="range"
                min="0" max="1" step="0.1" default="0.8" />

        </properties>
    </map-source>
  
    <map-source name="vector-parcels" type="mapserver-wfs">
        <file>demo/parcels/parcels.map</file>
        <param name="typename" value="ms:parcels"/>
        <transform attribute="EMV_TOTAL" function="number"/>

        <layer name="big-money">
            <style><![CDATA[
            {
                "fill-color": "#ffa500"
            }
            ]]></style>
            <filter><![CDATA[
            [">", "EMV_TOTAL", 500000]
            ]]></filter>

        </layer>

        <layer name="parcels" selectable="true" title="Parcels">
            <style><![CDATA[
            {
                "line-color" : "#00A138",
                "line-width" : 2
            }
            ]]></style>
            <template name="identify"><![CDATA[
                <div class="identify-result">
                    <div class="feature-class">Vector Parcel (remote template)</div>
                    <div class="item"><label>PIN:</label> {{ properties.PIN }}</div>
                    <div class="item"><label>Owner Name:</label> {{ properties.OWNER_NAME }}</div>
                    <div class="item">
                        <label>Est. Market Value:</label> {{ properties.EMV_TOTAL }}
                    </div>
                    <div class="item"><label>Acres:</label> {{ properties.ACRES_POLY }}</div>
                </div>
            ]]></template>
        </layer>
    </map-source>

	<map-source name="pipelines" type="mapserver" title="Pipelines">
		<file>demo/pipelines/pipelines.map</file>
		<layer name="pipelines" status="off">
            <template name="identify"><![CDATA[
            <div>
                <div class="feature-class pipelines">
                Pipeline
                </div>
                <div class="item">
                    <label>Name:</label> {{ properties.name }}
                </div>
                <div class="item">
                    <label>Owner:</label> {{ properties.owner }}
                </div>
            </div>
            ]]></template>
        </layer>
		<param name="FORMAT" value="image/png"/>
	</map-source>

	<!-- Demo of parcels as points. -->
    <!--
	<map-source name="parcel_points" type="mapserver" up="true" down="true" title="Parcel Points">
		<file>demo/parcels/parcels.map</file>
		<layer name="parcel_points"/>
		<param name="FORMAT" value="image/png"/>
	</map-source>
    -->

	<map-source name="parcels" type="mapserver" up="true" down="true" title="Parcels">
		<file>demo/parcels/parcels.map</file>
		<layer name="parcels" status="on">
            <template name="identify"><![CDATA[
                <div class="identify-result">
                    <div class="feature-class">Parcel</div>
                    <div class="item"><label>PIN:</label> {{ properties.PIN }}</div>
                    <div class="item"><label>Owner Name:</label> {{ properties.OWNER_NAME }}</div>
                    <div class="item">
                        <label>Est. Market Value:</label> <i>{{ properties.EMV_TOTAL }}</i>
                    </div>
                    <div class="item"><label>Acres:</label> {{ properties.ACRES_POLY }}</div>
                </div>
            ]]></template>
        </layer>
		<layer name="parcels_points"/>
		<param name="FORMAT" value="image/png"/>
		<!-- this is used only for testing the group-functionality -->
		<!--
		-->
		<layer name="parcels_group"/>
		<layer name="all"/>
	</map-source>

	<!--
	 * This map-source is used solely for testing geomose
	 * with international characters.
	 -->
	<map-source name="international" type="mapserver">
		<file>demo/i18n/utf8_polys.map</file>
		<layer name="testing"/>
	</map-source>

	<map-source name="borders" type="mapserver" title="City and County Borders">
		<file>demo/statedata/basemap.map</file>
		<layer name="city_poly" status="off"/>
		<layer name="county_borders" status="off"/>
	</map-source>

	<map-source name="iastate" type="wms">
		<url>https://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?</url>
		<layer name="nexrad-n0r"/>
		<param name="FORMAT" value="image/png"/>
		<param name="TRANSPARENT" value="TRUE"/>
	</map-source>


	<map-source name="ags" type="ags">
		<url>https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer</url>
		<layer name="NatGeo_World_Map"/>
		<param name="FORMAT" value="png"/>
        <param name="cross-origin" value="anonymous"/>
	</map-source>

    <map-source name="ags-vector-dc16" type="ags-vector">
        <url>https://gis2.co.dakota.mn.us/arcgis/rest/services/DCGIS_OL_Transportation/MapServer/16</url>
        <layer name="railroads" selectable="true" title="Railroads">
            <style><![CDATA[
            {
                "line-color" : "#010138",
                "line-width" : 2
            }
            ]]></style>
            <template name="identify"><![CDATA[
                <div class="identify-result">
                    <div class="feature-class">Dakota County Rail</div>
                    <div class="item"><label>Name:</label> {{ properties.FEAT_NM1 }}</div>
                </div>
            ]]></template>
            <template name="search"><![CDATA[
                <div class="search-result">
                    <div class="search-label">
                        {{ properties.FEAT_NM1 }}
                    </div>
                    <div class="search-action">
                        <div style="padding: 2px">
                            <a onClick="app.zoomToExtent([{{ properties.boundedBy | join }}], 'EPSG:3857')" class="zoomto-link">
                                <i class="fa fa-search"></i>
                            </a>
                        </div>
                    </div>
                </div>
            ]]></template>
        </layer>
    </map-source>

    <!-- This layer is very large.  It will take awhile to load, will slow down the browser
         once it is loaded.  Thus, it is not "in" the demo, but it is left here because it
         a good complex example and is a great stress test for the ags-vector driver. -->
    <!--map-source name="ags-vector-dc20" type="ags-vector">
        <url>https://gis2.co.dakota.mn.us/arcgis/rest/services/DCGIS_OL_Transportation/MapServer/20</url>
        <layer name="roads" selectable="true" title="Streets">
            <style><![CDATA[
            {
                "line-color" : "#A1A138",
                "line-width" : 2
            }
            ]]></style>

            <template name="identify"><![CDATA[
                <div class="identify-result">
                    <div class="feature-class">Dakota County Streets</div>
                    <div class="item"><label>Street Name:</label> {{ properties.STREET_NAME }}</div>
                    <div class="item"><label>City:</label> {{ properties.CITY_L }}</div>
                </div>
            ]]></template>
            <template name="search"><![CDATA[
                <div class="search-result">
                    <div class="search-label">
                        {{ properties.STREET_NAME }}
                    </div>
                    <div class="search-action">
                        <div style="padding: 2px">
                            <a onClick="app.zoomToExtent([{{ properties.boundedBy | join }}], 'EPSG:3857')" class="zoomto-link">
                                <i class="fa fa-search"></i>
                            </a>
                        </div>
                    </div>
                </div>
            ]]></template>
            <template name="select" alias="search"/>
            <template name="gridColumns"><![CDATA[
            [
                {
                    "title": ""
                },
                {
                    "title": "Street Name",
                    "property" : "STREET_NAME",
                    "filter" : {
                        "type" : "list"
                    }
                },
                {
                    "title" : "City Left",
                    "property" : "CITY_L",
                    "sortAs" : "string",
                    "filter" : {
                        "type" : "list"
                    }
                },
                {
                    "title" : "City Right",
                    "property" : "CITY_R",
                    "sortAs" : "string",
                    "filter" : {
                        "type" : "list"
                    }
                }
            ]
            ]]></template>
            <template name="gridRow"><![CDATA[
            <tr
              onmouseenter="app.highlightFeatures({'OBJECTID' : '{{ properties.OBJECTID }}'}, true)"
              onmouseleave="app.clearHighlight()"
            >
                <td>
                  <a onClick="app.zoomToExtent([{{ properties.boundedBy | join }}], 'EPSG:3857')" class="zoomto-link">
                    <i class="fa fa-search"></i>
                  </a>
                </td>
                <td>
                  {{ properties.STREET_NAME}}
                </td>
                <td>{{ properties.CITY_L }}</td>
                <td>{{ properties.CITY_R }}</td>
            </tr>
            ]]></template>

        </layer>
    </map-source-->

    <map-source name="openstreetmap" type="xyz">
        <layer name="osm_mapnik" status="on">
            <attribution><![CDATA[
                &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> Contributors.
            ]]></attribution>
        </layer>
        <url>https://a.tile.openstreetmap.org/{z}/{x}/{y}.png</url>
        <url>https://b.tile.openstreetmap.org/{z}/{x}/{y}.png</url>
        <url>https://c.tile.openstreetmap.org/{z}/{x}/{y}.png</url>

        <param name="cross-origin" value="anonymous"/>
    </map-source>

	<map-source name="lmic" type="mapserver">
		<file>demo/wms/wms_proxy.map</file>
		<layer name="mncomp">
            <legend type="nolegend"/>
        </layer>
	</map-source>

	<!--
		The catalog defines how the layers will be displayed in the catalog tab.
	-->
	<catalog>
		<!-- Layer for testing international character support.
		<layer title="Test International Characters" src="international/testing"/>
		-->
		<group title="Overlays" expand="true">
			<group title="County Layers" expand="false">

				<layer src="parcels/parcels" metadata="true" legend-toggle="true" tip="this a parcel layer, y'all" refresh="10">
					<metadata>https://raw.githubusercontent.com/geomoose/gm3-demo-data/main/demo/parcels/LICENSE</metadata>
				</layer>
				<layer title="Parcel Points" src="parcels/parcels_points" minscale="6000" maxscale="20000" status="off"/>
                <layer title="Expensive Parcels" src="vector-parcels/big-money"/>
				<layer title="City and County Boundaries" src="borders/county_borders;borders/city_poly"/>
				<layer title="AGS Dakota County Rail" src="ags-vector-dc16/railroads"/>
				<!--layer title="AGS Dakota County Streets" src="ags-vector-dc20/roads"/-->
			</group>
			<layer src="pipelines/pipelines"></layer>
			<layer title="Weather Radar" src="iastate/nexrad-n0r" />
		</group>

		<group title="Backgrounds" expand="true">
			<layer title="Reprojected Regional Aerial" src="lmic/mncomp" show-legend="false" legend="false" fade="true" unfade="true"/>

			<layer title="OpenStreetMap - Mapnik" src="openstreetmap/osm_mapnik" legend="false" fade="true" unfade="true" status="on"/>
			
			<layer title="ArcGIS Rest Example" src="ags/NatGeo_World_Map" show-legend="false" legend="false" fade="true" unfade="true"/>
		</group>
	</catalog>

</mapbook>
