I want to move gmaps.js on jsfiddle, but it doesn't work.

Asked 1 years ago, Updated 1 years ago, 76 views

I want to run gmaps.js on jsfiddle, but it doesn't work

How can I set it up?

http://jsfiddle.net/Lsx7fabb/

var type=';

function ryo(){
  type = 'ryo';
  alert("Send location information as yomiireru.");
}

function maro() {
  type = 'maro';
  alert("Send location information calmly.");
}

window.onload=function(){

  setInterval(function(){
    GMaps.geolocate({
      success:function(position){
        dataStore.send({
          lat:position.coords.latitude,
          lon —position.coords.longitude,
          type —type
        });
      },
      error: function(error) {
        console.log('Georocation failed:'+error.message);
      },
      not_supported: function() {
        console.log('Your browser does not support geolocation');
      },
      always:function(){
        console.log('done');
      }
    });
  }, 5000);


  varlat = 35.710285;
  varlng = 139.77714;
  varmap = new GMaps({
    div: "#map",
    lat —lat,
    lng —lng,
    zoom —17
  });

  dataStore.on('send', function(data){
    varlat = data.value.lat,
      lng = data.value.lon;

    varimg=';
    if(data.value.type=='ryo'){
      img='http://i.gyazo.com/7502afdcf0bbcc1f6d8f3d85e66616f6.png';
    } else if(data.value.type=='maro'){
      img='http://i.gyazo.com/f7b2e1dac073595c3e53a260413aec14.png';
    }

    map.setCenter(lat,lng);
    map.addMarker({
      lat —lat,
      lng —lng,
      title: "LIG Employee",
      icon: img,
      infoWindow: {
        content: "<p>LIG employees are <br/>Coco!</p>"
      }
    });
    console.log('recieve', data.value);
  });

};


<
divide = "map" >
  <
  button onClick="ryo()">
  good-for-nothing

  <
  button onClick="maro()">
  Of course 
<link rel="stylesheet" href="./foundation.css">style>@charset"utf-8";
#map{
  height —400px;
}

</style>
<title>gmaps Sample</title>


<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="./gmaps.js"></script>
<script src="http://cdn.mlkcca.com/v0.2.8/milkcocoa.js"></script>
<script>
  vardataStore=new MilkCocoa("https://{io-bi2tzwnsk}.mlkcca.com").dataStore('chat');

javascript milkcocoa

2022-09-30 20:28

3 Answers

If you want to load an external JavaScript file, add it to External Resources on the left.

In this case, I think you can use gmaps.js by adding //cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.12/gmaps.min.js.

However, since you don't seem to know how to use jsfiddle fundamentally, you should practice using simple code.


2022-09-30 20:28

There are multiple issues with this jsfiddle.

First of all, the use of jsfiddle is wrong. The correct usage is as follows: jsfiddle

  • Insert the js library into the "External Resources" on the left
  • Insert only HTML in HTML field.CSS and js similarly
  • Relative URLs are not allowed.Your browser cannot find ./gmaps.js or foundation.css that you used.If possible, use the following CDN:
    • foundation://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/foundation.css
    • gmaps://cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.12/gmaps.min.js
  • The function attached to the
  • button should be created with the event handler, and the JavaScript field in jsfiddle is a different scope.
  • You need an API Key to use the Google Maps library.The URL is as follows. https://maps.googleapis.com/maps/api/js?key=API_KEY

    Without the Google Maps API Key, you cannot see the results.

  • foundation://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/foundation.css
  • gmaps://cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.12/gmaps.min.js

You need an API Key to use the Google Maps library.The URL is as follows. https://maps.googleapis.com/maps/api/js?key=API_KEY

Without the Google Maps API Key, you cannot see the results.


2022-09-30 20:28

How about changing the gmaps.js path to CDN?

For example, //cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.12/gmaps.min.js might be available.

(However, the linked code in the question does not separate HTML from JS and CSS, and it does not seem to work as it is.)


2022-09-30 20:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.