How to create multiple markers from (WGS84) json data

I am trying to create multiple markers from a open json data :http://opendata2.epa.gov.tw/UV/UV.json

firstly, i had the json data decode and show all the data in label.
secondly, i use for each loop to get the data i want and show them in another label in order.

there are no problem from above.

but when i try to use map.CreateMarker in the loop , i get error

attached my code:

so how should i correct my code if i want to create multiple marker from my json data??

Thank you in advance.

1 Like

To CreateMarker, your geocoordinates must be in geographic format (decimal latitude, longitude format).

Your data is in WGS84 format and in degrees,minutes,seconds. Fore example 20:00",“SiteName”:“花蓮”,“UVI”:“0.00”,“WGS84Lat”:“23,58,30”,“WGS84Lon”:“121,36,48”}] (degrees,minutes,seconds)

As an example, convert 23,58,30 to 23.9750000000 deg. latitude
and 123,36,48 to 123.6133333333 deg. longitude.

The geocoordinates must be entered in CreateMarker in decimal values . This conversion example assumes the Latitude is in the northern hemisphere and the longitude is degrees east.

There are conversion formulas to convert dd,mm,ss to decimal degrees and online converters

Regards,
Steve

2 Likes

Thank you @SteveJG , i’ve tried another file with the correct format , it works!

But the markers created by above method does not have the properties like infobox …etc. is it possible to add infobox to those marker? and also have the same event like when marker.click?

Thank you for your help!

Very good. I am glad you found a data set using decimal geocoordinates.You also could have written a small Procedure to convert the dd,mm,ss to decimal ...

Yes it is possible to add an infobox from the geojson information. The CreateMarkers only creates a Marker at the location. The National Parks tutorial demonstrates how to plot multiple run time markers using a csv file to an OpenStreetMap and how to create and populate the info box. Use the ideas there by selecting the items from the geojson data stream (similar to how you isolated the latitude and longitude) to provide what you want (perhaps location and UIV number) in the infobox. Instead of the csv, use the topics parsed from the geojson.

Yes, you will be able to click the marker to get the popup. Try the tutorial and see how it works. It is probably what you want to do.

1 Like

Very glad you got it working. You hopefully got a resulting map that looks something like this:

,

Thanks for letting us know @anna770822 :slight_smile: :wink: This was made converting the WGS84 latitude/longitude dd,mm,ss to decimal degrees on the fly with internal Block code

1 Like

@SteveJG Thank you so much!

I follow your instruction for the convertDMSDecimalDeg procedure and also the National Park for the marker infobox properties. it all works out!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.