GithubHelp home page GithubHelp logo

Cannot load ng2-map about map HOT 13 CLOSED

ng2-ui avatar ng2-ui commented on September 18, 2024
Cannot load ng2-map

from map.

Comments (13)

allenhwkim avatar allenhwkim commented on September 18, 2024 1

You need to install typings for google.maps. Please look at typings.json in this repo.

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

Thanks, I will look into ASAP. Meanwhile, if you provide me a plunker example, that makes me a lot easier to debug your issue.

from map.

nhan-huynhvan avatar nhan-huynhvan commented on September 18, 2024

Can I push code into my git?

from map.

rockways3002 avatar rockways3002 commented on September 18, 2024

Here is my github https://github.com/rockways3002/example-ng2-map.git

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

Thanks for trying this map. af far as I see , your git does not have systemjs.config.js, which points where ng2-map is and how to use it.

from map.

rockways3002 avatar rockways3002 commented on September 18, 2024

Hi allenhwkim,
I'm updated systemjs.config.js now. Can you help me check one more time. :)

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

Here are the things made to make your git repo to work.

diff --git a/app/app.component.ts b/app/app.component.ts
index d79bc51..a59ad5f 100644
--- a/app/app.component.ts
+++ b/app/app.component.ts
@@ -7,7 +7,7 @@ import { NG2_MAP_DIRECTIVES  } from "ng2-map";
    selector: 'my-app',
    template: `
        <div id="map">
-           <ng2-map  [center]="Brampton, Canada"></ng2-map>
+                   <ng2-map center="Brampton, Canada"></ng2-map>
        </div>
    `,
    directives: [NG2_MAP_DIRECTIVES],
@@ -15,4 +15,4 @@ import { NG2_MAP_DIRECTIVES  } from "ng2-map";

 export class AppComponent {

-}
\ No newline at end of file
+}
diff --git a/index.html b/index.html
index 32e29ce..e24c3a6 100644
--- a/index.html
+++ b/index.html
@@ -10,6 +10,8 @@
     <script src="node_modules/zone.js/dist/zone.js"></script>
     <script src="node_modules/reflect-metadata/Reflect.js"></script>
     <script src="node_modules/systemjs/dist/system.src.js"></script>
+    <script src="https://npmcdn.com/[email protected]/lib/typescript.js"></script>
+
     <!-- 2. Configure SystemJS -->
     <script src="systemjs.config.js"></script>
     <script>
@@ -20,4 +22,4 @@
   <body>
     <my-app>Loading...</my-app>
   </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/systemjs.config.js b/systemjs.config.js
index 7b37afd..e458308 100644
--- a/systemjs.config.js
+++ b/systemjs.config.js
@@ -13,10 +13,10 @@
   };
   // packages tells the System loader how to load when no filename and/or no extension
   var packages = {
-    'app':                        { main: 'main.js',  defaultExtension: 'js' },
+    'app':                        { main: 'main.ts',  defaultExtension: 'ts' },
     'rxjs':                       { defaultExtension: 'js' },
     'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
-    'ng2-map':                    { main: 'index.js', defaultExtension: 'js' }
+    'ng2-map':                    { main: 'dist/index.js', defaultExtension: 'js' }
   };
   var ngPackageNames = [
     'common',
@@ -43,6 +43,10 @@
   // Add package entries for angular packages
   ngPackageNames.forEach(setPackageConfig);
   var config = {
+    transpiler: 'typescript', //use typescript for compilation
+    typescriptOptions: {      //typescript compiler options
+      emitDecoratorMetadata: true
+    },
     map: map,
     packages: packages
   };

You may not need all of them, but at least it would be helpful for you.

Please follow README and don't forget to add api key if your domain is new or test on localhost.

NOTE: if you domain is new, and you are having api key error, please specify your api key like the following

import { NG2_MAP_DIRECTIVES, Ng2MapComponent } from "ng2-map";  // <--- this
// Ng2MapComponent.apiUrl = "https://maps.google.com/maps/api/js?key=YOUR_KEY";  // ???

@Component({ ... })
export class AppComponent {
  constructor() {
    Ng2MapComponent.apiUrl = "https://maps.google.com/maps/api/js?key=YOUR_KEY";
  }
}

from map.

rockways3002 avatar rockways3002 commented on September 18, 2024

You are very kind! :)
Thank you so much!

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

You are welcome. If you don't mind, please add a star on this repo, so that other developer can use it.

from map.

rockways3002 avatar rockways3002 commented on September 18, 2024

capture
I'm changed to the same of you, but not working :(

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

I think you are doing strict type checking. change .apiUrl to ['apiUrl']. That may work

from map.

rockways3002 avatar rockways3002 commented on September 18, 2024

HOw about Cannot find namespace 'google'.

from map.

allenhwkim avatar allenhwkim commented on September 18, 2024

Now it uses .umd.js, typescript errors shouldn't be matter any more

from map.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.