I have two JSON files named marker.json and marker.json0 that contain different latitude and longitude coordinates. To load them, I need to rename .json0 to .json (and vice versa), so that the new data from marker.json0 now resides in marker.json. This way, the JavaScript file responsible for handling AJAX requests can parse the data and display markers and infowindows on the map.
In the JavaScript file, there are two functions -
searchAddress
andremoveAddress
, triggered by user clicks on "cerca" or "cancella" buttons respectively. The purpose of these functions is to manipulate the JSON array to show or hide markers and infowindows on the map. After editing the code, I encountered new errors related to undefined variables and missing function definitions when interacting with the buttons.
Here's an update to the JS file:
// Updated JavaScript code will go here
This first JSON array contains information like latitudes, longitudes, titles, and content needed for the map visualization based on the parsed data from the JavaScript file.
[
{
"title": "Paolo",
"latitude": 41.897115,
"longitude": 12.513300,
"content": "Cooperativa fornitrice di servizi sociali,<br/> Viale Eleonora D'Arborea 12<br/> 00162 Roma<br/> <a href='http://www.prassiericerca.com' target='_blank'>Prassi e Ricerca</a>",
"icon": "img/orange-dot.png",
"coords": "1, 1, 1, 20, 18, 20, 18 , 1",
"type": "poly"
},
// Additional entries...
]
This second JSON array contains updated information meant to replace the previous data once the file names are switched between .json and .json0. The loading of JSON files and mapping of new data are handled within the JS file.
[
{
"title": "Bar dei Pini",
"latitude": 41.897115,
"longitude": 12.513300,
"content": "Specialita Gelato Artigianale<br/> Viale Eleonora D'Arborea 12<br/> 00162 Roma<br/> <a href='http://www.prassiericerca.com' target='_blank'>Prassi e Ricerca</a>",
"icon": "img/pink-dot.png",
"coords": "1, 1, 1, 20, 18, 20, 18 , 1",
"type": "poly"
},
// Additional entries...
]
The page does not require reloads as long as one of the JSON files maintains the .json extension after renaming.