• Hello, this plugin is cool

    how can I show multiple fields from a Geojson file on the same click popup event?

    this is the shortcode I’m using but it shows just one field:

    [leaflet-geojson src=”file.geojson” popup_property=”field-01″]

    Thanks for the help !

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author bozdoz

    (@bozdoz)

    Actually I had done this only a couple of months ago but I don’t think I wrote it in the documentation. Check out this link: https://github.com/bozdoz/wp-plugin-leaflet-map/issues/46

    To do what you want to do, you could put the template popup within the shortcode tags and use {field-01} as the variable. So, something like:

    [leaflet-geojson src=”file.geojson”]
    {field-01}
    {field-02}
    {field-03}, and add any extra text
    [/leaflet-geojson]

    Thread Starter wdprafael

    (@wdprafael)

    I’m able to get one field out of the geojson but I’m not sure why just one is showing up, do I have to reference the source each time for each field?

    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
    Plugin Author bozdoz

    (@bozdoz)

    The popup text is either placed in a “message” variable in the shortcode, or a “popup_property” variable in the shortcode, or within the shortcode tags, you can type whatever you want, using {property_name} syntax to use a property value. The example I gave should include fields 01 through 03 with extra text in the popup; I would encourage you to try it out, or give me a link to either your site or the geoJSON you’re using for me to look at.

    Thread Starter wdprafael

    (@wdprafael)

    thanks

    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
    Thread Starter wdprafael

    (@wdprafael)

    okay, I think I’m understating this a little better, so I tried this and I was able to get the two fields to show:

    [leaflet-geojson src=”…../GIS_Cemetery_Plots_01.geojson”]
    First Name{} {FIRST_NA}
    Last Name {LAST_NA}
    [/leaflet-geojson]

    I have a few questions though, I noticed that if I remove the empty variable {} after the First Name text then the {FIRST_NA} doesnt show, which is a field from the GeoJSON, is my syntax wrong for what I’m trying to do ?, it’s showing both fields like that I’m just curious why that happens, these are other examples I tried:

    First Name{FIRST_NA} {FIRST_NA} — doesnt show FIRST_NA
    First Name{RESERVED} {FIRST_NA} — Reserved is another field, it shows FIRST_NA but not RESERVED data
    First Name{randomtext} {FIRST_NA} — anytext inside the variable, it shows FIRST_NA

    also is there anyway to put both field one after the other ?, like:

    Full name: FIRST_NA, LAST_NA

    currently on the popup it shows one below the other like:

    First name FIRST_NA
    Last name LAST_NA

    currently I have it like this:

    [leaflet-map lat=50.066362 lng=-110.794546 zoom=17]
    [leaflet-geojson src=”…../GIS_Cemetery_Plots_01.geojson”]
    First Name{} {FIRST_NA}
    Last Name {LAST_NA}
    [/leaflet-geojson]

    is the shorcode [leaflet-map] in the first line necessary ? I noticed that if I remove it, it doesnt show the map, does it have to be like that? having the [leaflet-map] shortcode then the [leaflet-geojson]

    thanks for the help

    Plugin Author bozdoz

    (@bozdoz)

    leaflet-map shortcode has to come first, yes; then you add to that map whatever other shortcodes you want.

    I have no idea why you would need to have an empty {} in that shortcode. Maybe you can send me a link to the geoJSON file.

    If you want both fields, one after the other, simply add {FIRST_NA}, {LAST_NA} within the shortcode tags.

    Thread Starter wdprafael

    (@wdprafael)

    This is the GeoJSON, it’s the first data row with the closing braces and bracket

    {
    “type”: “FeatureCollection”,
    “name”: “GIS_Cemetery_Plots_01”,
    “crs”: { “type”: “name”, “properties”: { “name”: “urn:ogc:def:crs:OGC:1.3:CRS84” } },
    “features”: [
    { “type”: “Feature”, “properties”: { “OBJECTID”: 1, “FeatId1”: 1668.0, “PLOT_NUM”: 3.0, “SUB_BLOCK”: 2.0, “BLOCK”: 1.0, “BLOCK_1”: 1.0, “SUB_BLOC_1”: 2.0, “PLOT_NUM_1”: 3.0, “BLOCK_SU_1”: “1;2;3”, “FIRST_NA”: “JOHN”, “LAST_NA”: “DOE”, “RESERVED”: “N”, “A_K_A_”: null, “FIRST_NA_2”: null, “LAST_NA_2”: null, “FIRST_NA_3”: null, “LAST_NA_3”: null, “F13”: null, “Shape_Leng”: 0.00010284529727000001, “Shape_Area”: 3.8193906129300001e-10 }, “geometry”: { “type”: “MultiPolygon”, “coordinates”: [ [ [ [ -110.794020139999986, 50.065609614000039 ], [ -110.793977721999966, 50.065609539000036 ], [ -110.793977759999962, 50.065600535000044 ], [ -110.794020178999972, 50.065600610000047 ], [ -110.794020139999986, 50.065609614000039 ] ] ] ] } }
    ]
    }

    I noticed that syntax shown on the GeoJSON.org site is different

    {
    “type”: “Feature”,
    “geometry”: {
    “type”: “Point”,
    “coordinates”: [125.6, 10.1]
    },
    “properties”: {
    “name”: “Dinagat Islands”
    }
    }

    • This reply was modified 6 years, 11 months ago by wdprafael.
    • This reply was modified 6 years, 11 months ago by wdprafael.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Multiple Geojson fields shown on popup ?’ is closed to new replies.