Uncaught Typeerror: Cannot Read Property 'lat' of Null
I am using leaflet to brandish a map and I wanted to identify markers onto it. I wanted to place the markers using data I got from an API call from geoNames. All the same whenever I endeavor to run the program it errors out with this bulletin.
Projection.SphericalMercator.js:19
Uncaught TypeError: Cannot read backdrop of zip (reading 'lat') at Object.project (Projection.SphericalMercator.js:19) at Object.latLngToPoint (CRS.js:7) at NewClass.projection (Map.js:938) at NewClass.latLngToLayerPoint (Map.js:959) at NewClass.update (Mark.js:149) at NewClass.onAdd (Marker.js:65) at NewClass._layerAdd (Layer.js:60) at NewClass.whenReady (Map.js:1414) at NewClass.addLayer (Layer.js:119) at NewClass.addLayer (Layer.js:273) I want to populate the map with markers based on information I retrieve and non have to difficult code it.
//Go country Info function countryInfoCall(countryCode) { $.ajax({ url: 'libs/php/getCountryInfo.php', type: 'Mail service', dataType: 'json', information: { country: countryCode }, //Successful Country Info AJAX call success: office(resultInfo) { continent = resultInfo['data'][0]['continent']; if (resultInfo.condition.proper name === "ok") { capital = resultInfo['data'][0]['upper-case letter']; $('#capitalCityDiv').html(capital); var capEncoded = encodeURIComponent(capital letter); switch(continent) { example 'AF': continent = "Africa"; $('#continentDiv').html(continent); break; case 'AN': continent = "Antartica"; $('#continentDiv').html(continent); pause; instance 'AS': continent = "Asia"; $('#continentDiv').html(continent); break; case 'European union': continent = "Europe"; $('#continentDiv').html(continent); break; case 'NA': continent = "North America"; $('#continentDiv').html(continent); pause; case 'OC': continent = "Oceania"; $('#continentDiv').html(continent); break; case 'SA': continent = "South America"; $('#continentDiv').html(continent); break; default: $('#continentDiv').html(resultInfo['data'][0]['continent']); break; } $('#currencyDiv').html(resultInfo['information'][0]['currencyCode']); population = resultInfo['data'][0]['population']; population = numberWithCommas(population); $('#populationDiv').html(population); areaInSqrKm = Math.round(resultInfo['data'][0]['areaInSqKm']).toString(); areaInSqrKm = areaInSqrKm + ' km<sup>ii</sup>'; $('#areaDiv').html(areaInSqrKm); var countryCodeA = countryCode; var north = resultInfo['data'][0]['north']; var south = resultInfo['data'][0]['southward']; var e = resultInfo['data'][0]['east']; var west = resultInfo['information'][0]['w']; currency = resultInfo['data'][0]['currencyCode']; } wikiLinksCallCap(capEncoded, countryCodeA); earthquakeCall(north, south, east, west); getCityList(northward, s, due east, w); //exchangeRateCall(openExchangeRatesApiKey); }, //Error in Exchange Rate call fault: function(jqXHR, textStatus, errorThrown) { console.log(textStatus + ' : ' + errorThrown); panel.log(jqXHR); } }); }; //Get city list role getCityList(north, s, east, west) { $.ajax({ url: 'libs/php/getCityList.php', type: 'POST', dataType: 'json', data: { north: north, south: south, eastward: e, west: west }, //Successful Muzzle call success: role(resultCity) { if (resultCity.condition.name === "ok") { var resultCityArray = resultCity['data']; var cityListArray = []; var countryCodeArray = []; for (let i = 0; i < resultCityArray.length; i++) { cityListArray.push button(resultCityArray[i]['name']); countryCodeArray.push button(resultCityArray[i]['countrycode']); } for (let j = 0; j < cityListArray.length; j++) { citySearch(cityListArray[j], countryCodeArray[j]); } } console.log(cityListArray); }, //Fault in City List Call fault: function(jqXHR, textStatus, errorThrown) { console.log(textStatus + ' : ' + errorThrown); console.log(jqXHR); } }); } //Go latlng for cities function citySearch(placename, countryCode) { $.ajax({ url: 'libs/php/wikiSearchCapital.php', type: 'POST', dataType: 'json', data: { placename: placename, lawmaking: countryCode }, //Successful AJAX Phone call success: function(resultWikiCity) { console.log(resultWikiCity) panel.log('Wikipedia Links Get'); if (resultWikiCity.status.name === 'ok') { var cityTitle = resultWikiCity['data'][0]['title']; var cityLat = resultWikiCity['information'][0]['lat']; var cityLng = resultWikiCity['information'][0]['lng']; marker = new L.marker([cityLat, cityLng], {icon: placeMarker}) .bindPopup(cityTitle) .addTo(markerLayerGroup); markerLayerGroup.addTo(map); nearbyPOIs(cityLat, cityLng); } }, //Error in Wikipedia Call error: part(jqXHR, textStatus, errorThrown) { console.log(countryCode); console.log(placename); console.log(textStatus + ' : ' + errorThrown); panel.log(jqXHR); } }); }; //Go Nearby Wiki for Markers function nearbyPOIs(lat, lng) { $.ajax({ url: 'libs/php/findNearbyWiki.php', type: 'POST', dataType: 'json', data: { lat: lat, lng: lng }, //Successful Post Code AJAX call success: function(resultNearWiki) { if (resultNearWiki.status.name === "ok") { //Create Marker console.log(lat); console.log(lng); panel.log(resultNearWiki); panel.log(JSON.stringify(resultNearWiki)); var nearWikiArray = resultNearWiki['information']['poi']; console.log(nearWikiArray); var nearWikiTypeClassArray = []; var nearWikiTypeNameArray = []; var nearWikiNameArray = []; var nearWikiLatArray = []; var nearWikiLngArray = []; for (i = 0; i < nearWikiArray.length; i++) { nearWikiTypeClassArray.push button(nearWikiArray[i]['typeClass']); nearWikiTypeNameArray.push button(nearWikiArray[i]['typeName']); nearWikiNameArray.push(nearWikiArray[i]['name']); nearWikiLatArray.push(nearWikiArray[i]['lat']); nearWikiLngArray.button(nearWikiArray[i]['lng']); } panel.log(nearWikiLatArray); console.log(nearWikiTypeNameArray); console.log(nearWikiNameArray); for (i = 0; i < nearWikiArray.length; i++) { createMarker(nearWikiLatArray[i], nearWikiLngArray[i], nearWikiNameArray[i], nearWikiTypeNameArray[i]); } markerLayerGroup.addTo(map); } }, //Error in Post Lawmaking Telephone call error: role(jqXHR, textStatus, errorThrown) { console.log(lat); console.log(lng); panel.log(textStatus + ' : ' + errorThrown); console.log(jqXHR); } }); }; function createMarker(lat, lng, proper noun, typeName) { marker = new L.marker(lat, lng, {icon: unknownMarker}) .bindPopup('Name: ' + proper name + 'nEstablishment: ' + typeName) .addTo(markerLayerGroup); } Get POIs
<?php
header("Access-Control-Let-Origin: *"); header("Access-Control-Allow-Headers: *"); header("Access-Control-Allow-Methods: Become, Postal service, OPTIONS"); header('Content-Type: application/json; charset=UTF-eight'); ini_set('display_errors', 'On'); error_reporting(E_ALL); $executionStartTime = microtime(true); $url='http://api.geonames.org/findNearbyPOIsOSMJSON?lat=' . $_REQUEST['lat'] .'&lng=' . $_REQUEST['lng'] . '&maxRows=15&radius=1&username=yajarobe'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, truthful); curl_setopt($ch, CURLOPT_URL, $url); $outcome = curl_exec($ch); curl_close($ch); $decode = json_decode($result,truthful); $output['status']['code'] = "200"; $output['status']['name'] = "ok"; $output['status']['description'] = "success"; $output['status']['returnedIn'] = intval((microtime(truthful) - $executionStartTime) * 1000) . " ms"; $output['information'] = $decode; echo json_encode($output); ?>
Get City List
<?php
header("Access-Command-Allow-Origin: *"); header("Access-Control-Allow-Headers: *"); header("Access-Control-Allow-Methods: GET, Mail, OPTIONS"); header('Content-Type: application/json; charset=UTF-viii'); ini_set('display_errors', 'On'); error_reporting(E_ALL); $executionStartTime = microtime(true); $url='http://api.geonames.org/citiesJSON?north=' . $_REQUEST['n'] . '&south=' . $_REQUEST['south'] . '&e=' . $_REQUEST['east'] . '&due west=' . $_REQUEST['westward'] . '&lang=en&maxRows=15&username=yajarobe'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $consequence = curl_exec($ch); curl_close($ch); $decode = json_decode($outcome,true); $output['status']['code'] = "200"; $output['status']['name'] = "ok"; $output['status']['description'] = "success"; $output['status']['returnedIn'] = intval((microtime(true) - $executionStartTime) * chiliad) . " ms"; $output['data'] = $decode['geonames']; echo json_encode($output); ?>
Get Country Info
<?php header("Access-Command-Allow-Origin: *"); header("Admission-Control-Allow-Headers: *"); header("Access-Control-Let-Methods: GET, Postal service, OPTIONS"); header('Content-Type: application/json; charset=UTF-viii'); ini_set('display_errors', 'On'); error_reporting(E_ALL); $executionStartTime = microtime(true); $url='http://api.geonames.org/countryInfoJSON?formatted=true&lang=en&country=' . $_REQUEST['country'] . '&username=yajarobe&manner=full'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, faux); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); curl_close($ch); $decode = json_decode($result,true); $output['status']['code'] = "200"; $output['status']['name'] = "ok"; $output['status']['description'] = "success"; $output['status']['returnedIn'] = intval((microtime(true) - $executionStartTime) * g) . " ms"; $output['data'] = $decode['geonames']; repeat json_encode($output); ?> I tried swapping out the for loop in the POIs phone call with a switch case and tried setting the information to global variables for which to call on subsequently but neither work. When I type in the url with the data I desire, it has the data I am trying to recollect, the data is too printed to the console, it merely won't let me admission it. Thanks in advance.
Source: Ask PHP
Source: https://askphpquestions.com/2021/09/30/uncaught-typeerror-cannot-read-properties-of-null-reading-lat-projection-sphericalmercator-js19/
Post a Comment for "Uncaught Typeerror: Cannot Read Property 'lat' of Null"