Пример #1
0
def main():
    api = MapFigApplication(studioURL="https://studio.mapfig.com", apiKey="Za40iR62wtzc8HWs4TgJhNSI8_wRcqMa")

    try:
        map = api.get(555)  # Tested on ID 508
        print map.getWholeDataArray()

    except Exception as ex:
        print ex.message
def main():
    api = MapFigApplication(studioURL="https://studio.mapfig.com", apiKey="Za40iR62wtzc8HWs4TgJhNSI8_wRcqMa")

    try:
        request = "ogr2ogr" # gdal_translate, ogr2ogr, ogrinfo
        options = "-f \"GeoJSON\"" #optional for request = ogrinfo
        sourceFileURL = "https://developers.google.com/kml/documentation/KML_Samples.kml"
        targetFileExtension = "json" # (not required for request = ogrinfo)

        gdal = Gdal(request, options, sourceFileURL, targetFileExtension) # '.json' not required for request = ogrinfo
        output = api.getGDALData(gdal)
        print output.text

    except Exception as ex:
        print ex.message
def main():
    api = MapFigApplication(studioURL="https://studio.mapfig.com", apiKey="Za40iR62wtzc8HWs4TgJhNSI8_wRcqMa")

    mapName = "My Map"
    mapHeight = 450
    mapWidth = 950
    mapZoom = 4
    mapCenter = Point(48.856614, 2.3522219)

    map = Map(mapName, mapHeight, mapWidth, mapZoom, mapCenter)
    map.setId(None)
    map.setLayerId(1)  # Default 1 or change it to the account owner's layer ID
    map.setGroupId(0)  # Default 0 or change it to the account owner's layer group ID
    map.setPassword("")  # Default NONE or change it to the Desire Password to protact the Map
    map.setUseCluster(False)  # Default False
    map.setOverlayEnable(False)  # Default False
    map.setOverlayTitle("")  # Default NONE
    map.setOverlayContent("")  # Default NONE
    map.setOverlayBlurb("")  # Default NONE
    map.setLegendEnable(False)  # Default False
    map.setLegendContent("HTML content here")  # Default NONE
    map.setProjectId(0)  # Default 0 or change it to the account owner's project ID
    map.setShowSidebar(True)  # Default True
    map.setShowExport(False)  # Default False
    map.setShowMeasure(False)  # Default False
    map.setShowMinimap(False)  # Default False
    map.setShowSearch(False)  # Default False
    map.setShowFilelayer(False)  # Default False # shows local file upload button
    map.setShowSvg(False)  # Default False
    map.setShowStaticSidebar(False)  # Default False
    map.setStaticSidebarContent("")  # Default NONE

    # Add Image Overlay Here
    name = "Overlay Title goes here"  # Will not be displayed
    upperRightCornor = Point(0.0, 0.0)  # Upper Right Cornor Of Overlay Image
    try:
        upperRightCornor.setLatLng("Canada")
    except Exception as ex:
        ex.message

    bottomLeftCornor = Point(0.0, 0.0)  # Upper Right Cornor Of Overlay Image
    try:
        bottomLeftCornor.setLatLng("United State Of America")
    except Exception as ex:
        ex.message

    imageUrl = "http: #www.YOUR_IMAGE_URL.com/PATH.JPG"
    popupContent = "<h3>Image Overlay Content here<h3>"
    imageOverlay1 = ImageOverlay(name, upperRightCornor, bottomLeftCornor, imageUrl, popupContent)  # Create the overlay

    map.addImageOverlay(imageOverlay1)  # Add as many overlays as you want

    try:
        marker1 = Marker(48.856614, 2.3522219000000177)

        marker1.setLocation("Paris, France")
        marker1.setDescription("<p>This is where you can write the <strong>HTML</strong> code too</p>")

        # Advance Properties
        marker1.setShowGetDirection(False)
        marker1.setShowInfoBox(False)
        marker1.setShowLocationOnPopup(True)
        marker1.setHideLabel(True)

        # Styling
        marker1.setMarkerStyle("")  # Default NONE, available options are (user,cog,leaf,home,.....)
        # Complete list can be found here http: #fortawesome.github.io/Font-Awesome/icons/
        marker1.setMarkerColor("")  # Default NONE, available options are
        # (Red,Blue,Green,Purple,Orange,Darkred,Lightred,Beige,Darkblue,Darkpurple,White,
        # Pink,Lightblue,Lightgreen,Gray,Black,cadetblue,Brown,Lightgray)

        map.addShape(marker1)

    except Exception as ex:
        print ex.message

    try:
        marker2 = Marker()
        marker2.setLatLng("Germany")

        marker2.setDescription("<p>This is where you can write the <strong>HTML</strong> code too</p>")

        # Advance Properties
        marker2.setShowGetDirection(False)
        marker2.setShowInfoBox(False)
        marker2.setShowLocationOnPopup(True)
        marker2.setHideLabel(True)

        # Styling
        marker2.setMarkerStyle("home")  # Default NONE, available options are (user,cog,leaf,home,.....)
        # Complete list can be found here http: #fortawesome.github.io/Font-Awesome/icons/
        marker2.setMarkerColor("red")  # Default NONE, available options are
        # (Red,Blue,Green,Purple,Orange,Darkred,Lightred,Beige,Darkblue,Darkpurple,White,
        #  Pink,Lightblue,Lightgreen,Gray,Black,cadetblue,Brown,Lightgray)

        map.addShape(marker2)

    except Exception as ex:
        print ex.message

    try:
        response = api.save(map)
        print response.text

        json_obj = response.json()
        print json_obj

    except Exception as ex:
        print ex.message