Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 3026
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 1, 20222022-06-01T23:41:48+00:00 2022-06-01T23:41:48+00:00

javascript – Error in Angular: earthquake_GeoJSONP.js:1 Uncaught ReferenceError: eqfeed_callback is not defined at earthquake_GeoJSONP.js:1:1

  • 0

[ad_1]

I’m trying to replicate the Importing Data into Maps (Importing Data into Maps) example to my angular project but I get the following error in console:

earthquake_GeoJSONP.js:1 Uncaught ReferenceError: eqfeed_callback is not defined
    at earthquake_GeoJSONP.js:1:1

app.component.ts

import { Component, OnInit } from '@angular/core';
import { Loader } from "@googlemaps/js-api-loader"

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
  title="map";

  ngOnInit() {

    let map: google.maps.Map;
    
    const loader = new Loader({
      apiKey: "AIzaSyB_Ti9BSc0Fjr8s-0Kd0kL8-JHVaDQnpMI"
    });
    
    loader.load().then(() => {
      const map = new google.maps.Map(document.getElementById("map") as HTMLElement, {
        zoom: 2,
        center: new google.maps.LatLng(2.8, -187.3),
        mapTypeId: "terrain",
      });

      // map.data.loadGeoJson('data.json');

      // Create a <script> tag and set the USGS URL as the source.
      const script = document.createElement("script");

      // This example uses a local copy of the GeoJSON stored at
      // http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojsonp
      script.src =
        "https://developers.google.com/maps/documentation/javascript/examples/json/earthquake_GeoJSONP.js";
      document.getElementsByTagName("head")[0].appendChild(script);

      const eqfeed_callback = function (results: any) {
        for (let i = 0; i < results.features.length; i++) {
          const coords = results.features[i].geometry.coordinates;
          const latLng = new google.maps.LatLng(coords[1], coords[0]);
      
          let marker = new google.maps.Marker({
            position: latLng,
            map: map,
          });
          // place marker in map
          marker.setMap(map)
        }
      };    
    });   
  }
}

app.component.html

<div id="map"></div>

app.component.css

 #map {
    height: 500px;
    width: 100%;
  }

Installed Packages

This is the googlemaps package that I installed in my project.

npm install @googlemaps/js-api-loader

My Angular version

Angular CLI: 13.3.7
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64

What my code shows

Just appear the map but without markers.

What I hope will appear

According to the Google Maps documentation at the following link: Importing Data into Maps

Thanks for your time and support!

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 2 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 4 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 3 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.