Display Lines and Polygon using a kml File

Display Lines and Polygon using a kml File

The Map section can display the following geometries :
  1. Points
  2. Lines 
  3. Polygons
Points can be created using the CMS or can be imported using a KML file.
Lines and Polygons are created by uploading a KML file into the map section.



1. KML Structure

If you don’t have coding skills, we recommend you use Google Maps to create your kml file. With Google Maps, you can easily create points and lines.

Note: that the Map section cannot support the formatting applied to your geometries in Google Maps. For instance, if you choose a color for a line, this color won’t be interpreted by the map section.

If you have coding skills, you can create a kml file where the following properties will be interpreted by the map section:
  1. Line weight
  2. Line color
  3. Polygon outer boundary color
  4. Polygon outer boundary weight
  5. Polygon inner color
Here are some code samples with the kml structure you must follow to have those properties displayed on your map.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark>
      <name>Line</name>
      <Style>
        <LineStyle>
          <width>10</width>
          <color>ff00ffff</color>
        </LineStyle>
      </Style>
      <LineString>
        <tessellate>1</tessellate>
       <coordinates>
          8.9648438,42.1634034,0.0 
          -4.3945312,39.6395376,0.0 -117.5976562,57.4212944,0.0 
          -112.6757812,36.3151251,0.0 
          -50.9765625,-15.2841851,0.0 
          24.2578125,-4.5654736,0.0 
          133.4179688,-22.268764,0.0 
          101.953125,36.7388841,0.0 
          39.7265625,58.9953112,0.0 
          -1.7578125,52.8027614,0.0 
          9.2175293,42.2366519,0.0
        </coordinates>
      </LineString>
    </Placemark>
    <Placemark>
        <name>Polygon</name>
        <Style>
          <LineStyle>
            <width>3</width>
            <color>ffff00ff</color>
          </LineStyle>
          <PolyStyle>
            <color>ff000000</color>
          </PolyStyle>
        </Style>
        <Polygon>
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing>
                    <coordinates>
                        -101.2703028084182,44.03484070243132,0
                        -93.50548036075496,32.23807715431979,0
                        -81.86615113861016,38.17061241766041,0
                        -101.2703028084182,44.03484070243132,0 
                    </coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
    </Placemark>
  </Document>
</kml>


2. Importing your Line or Polygon

When you add a map section, you have to choose between using the CMS or an external plugin

CMS source
If you choose Map, you can upload a kml file to display lines and polygons.
Go to the Settings tab of the section and upload your file under “Routes.”

You benefit from a powerful way to add metadata to your points, thanks to the various options provided by the CMS. You can also display other geometries with the file import.

Note: if you upload a kml file that contains points, lines, and polygons under the “Route” area of the section. All the geometries will be displayed on the map with the points included.



External Source

If you choose kml, you will have to upload two files to get the map section working properly:
  1. 1 km file (or source URL) with the points. Providing the points file is mandatory to have the section working
  2. 1 km file with lines and polygons
Note: if you upload a kml file that contains points, lines and polygons under the “Points” area of the section, only points will be displayed on the map.

On the contrary, if you upload a kml file that contains points, lines, and polygons under the “Route” area of the section, all the geometries will be displayed on the map.


    • Related Articles

    • Import a Multipoint KML File

      1. Add a KML Map Section The Map section allows you to display and customize geo-targeted points on a map in your Muse mBaaS app. 1. In the left swipe menu, go to Design & Structure > Structure > Sections 2. Click the green button "Add a section" ...
    • Content Management System (CMS) Sections

      1. Add CMS sections CMS sections allow you to create and manage your content directly from the back office. Add a new CMS section :  1. In the left swipe menu, go to Design & Structure > Structure > Sections 2. Click the green button "Add a section" ...
    • Create a Map via a KML File with Google Maps

      1. Creation of a MapTo begin the creation of your map, open Google Map in your browser: https://www.google.fr/maps/ In the menu, click on "Your places." Click on the Maps tab and select "Create a map" at the bottom of the page. 2. AttentionOnce you ...
    • Duplicate CMS Content

      This feature is useful if you wish to reuse the existing content of your app. For instance: - to create a second article in a different language, so you only need to translate the text in the copy of the article. - to add a new event very similar to ...
    • Custom Code in your App Content

      Muse mBaaS offers the possibility to use external code within the app. There are a few options that allow you to do this: plugins, APIs, custom feeds, HTML sections/Widgets, etc. 1. Add a Plugin Section An HTML5 plugin for Muse mBaaS is a bundle of ...