Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

絶対はずさないお店を検索できるwebアプリケーションをリリースするまで③

Posted at

javascript 文字列を数値に変換するメソッド

parseFloat メソッド名
javascript 文字列を数値に変換するメソッドになる。
グーグルマップ表示
let timer = setInterval(() => {
    if (window.mapLoaded) {
      clearInterval(timer);
      console.log(parseFloat(this.cooks[0].lat))
      const map = new window.google.maps.Map(this.$refs.map, {
                center: { lat: parseFloat( this.cooks[0].lat), 
                lng: parseFloat(this.cooks[0].lng) },
parseFloatの使い方(緯度経度)
center: { lat: parseFloat( this.cooks[0].lat), 
                lng: parseFloat(this.cooks[0].lng) },

今回、緯度経度の文字列を数値に変換する
 lat: parseFloatで、緯度の文字列を数値に変換しますよ〜と宣言する。
( this.cooks[0].lat)でcooksの中身の緯度を取得する。
経度も同様に、  lng: parseFloatで、経度の文字列を数値に変換しますよ〜と宣言する。
(this.cooks[0].lng) },ででcooksの中身の経度を取得する。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?