Menu
Close

Bezier Curve Dashed Polyline

3 km
mappls.com Map Data © MapmyIndia | Report

Sample Implementation

    
      <span class="pln">
      </span><span class="tag">&lt;html&gt;</span><span class="pln">
        </span><span class="tag">&lt;head&gt;</span><span class="pln">
          </span><span class="tag">&lt;title&gt;</span><span class="pln">Bezier Curve Dashed Polyline</span><span class="tag">&lt;/title&gt;</span><span class="pln">
          </span><span class="tag">&lt;meta</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"viewport"</span><span class="pln"> </span><span class="atn">content</span><span class="pun">=</span><span class="atv">"initial-scale=1.0"</span><span class="tag">&gt;</span><span class="pln">
          </span><span class="tag">&lt;meta</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"utf-8"</span><span class="tag">&gt;</span><span class="pln">
          </span><span class="tag">&lt;style&gt;</span><span class="pln">
          html</span><span class="pun">,</span><span class="pln">
          body</span><span class="pun">,</span><span class="pln">
          </span><span class="com">#map {</span><span class="pln">
            margin</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
            padding</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln">
            width</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100</span><span class="pun">%;</span><span class="pln">
            height</span><span class="pun">:</span><span class="pln"> </span><span class="lit">100vh</span><span class="pun">;</span><span class="pln">
          </span><span class="pun">}</span><span class="pln">
                          
          </span><span class="tag">&lt;/style&gt;</span><span class="pln">
             &lt;script src="https://apis.mappls.com/advancedmaps/api/</span><span class="tag">&lt;Token&gt;</span><span class="pun">/</span><span class="pln">map_sdk</span><span class="pun">?</span><span class="pln">layer</span><span class="pun">=</span><span class="pln">vector</span><span class="pun">&amp;</span><span class="pln">v</span><span class="pun">=</span><span class="lit">3.0</span><span class="pun">&amp;</span><span class="pln">callback</span><span class="pun">=</span><span class="pln">initMap1</span><span class="str">" defer async&gt;</span><span class="tag">&lt;/script&gt;</span><span class="pln">
            </span><span class="tag">&lt;/head&gt;</span><span class="pln">
        </span><span class="tag">&lt;body&gt;</span><span class="pln">
                    </span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"map"</span><span class="tag">&gt;&lt;/div&gt;</span><span class="pln">
                        </span><span class="tag">&lt;script&gt;</span><span class="pln">
        curveLine </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">p</span><span class="pun">,</span><span class="pln"> call</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> strt</span><span class="pun">,</span><span class="pln"> end</span><span class="pun">,</span><span class="pln"> ang </span><span class="pun">=</span><span class="pln"> </span><span class="lit">45</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">p</span><span class="pun">.</span><span class="pln">start </span><span class="pun">!=</span><span class="pln"> </span><span class="kwd">undefined</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> strt </span><span class="pun">=</span><span class="pln"> p</span><span class="pun">.</span><span class="pln">start </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">p</span><span class="pun">.</span><span class="pln">end </span><span class="pun">!=</span><span class="pln"> </span><span class="kwd">undefined</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> end </span><span class="pun">=</span><span class="pln"> p</span><span class="pun">.</span><span class="pln">end </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">p</span><span class="pun">.</span><span class="pln">angle </span><span class="pun">!=</span><span class="pln"> </span><span class="kwd">undefined</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> ang </span><span class="pun">=</span><span class="pln"> p</span><span class="pun">.</span><span class="pln">angle </span><span class="pun">};</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ang </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">45</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="str">"Angle should be less than 45."</span><span class="pun">);</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">strt </span><span class="pun">||</span><span class="pln"> </span><span class="pun">!</span><span class="pln">end</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="str">"Start and End point required."</span><span class="pun">);</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> st_lat </span><span class="pun">=</span><span class="pln"> strt</span><span class="pun">.</span><span class="pln">lat</span><span class="pun">,</span><span class="pln"> st_lng </span><span class="pun">=</span><span class="pln"> strt</span><span class="pun">.</span><span class="pln">lng</span><span class="pun">,</span><span class="pln"> end_lat </span><span class="pun">=</span><span class="pln"> end</span><span class="pun">.</span><span class="pln">lat</span><span class="pun">,</span><span class="pln"> end_lng </span><span class="pun">=</span><span class="pln"> end</span><span class="pun">.</span><span class="pln">lng</span><span class="pun">,</span><span class="pln"> fx </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> fy </span><span class="pun">=</span><span class="pln"> ang </span><span class="pun">&lt;</span><span class="pln"> </span><span class="lit">45</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="lit">0.8</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> points </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[],</span><span class="pln"> path </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[],</span><span class="pln"> resolution </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0.01</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> bearing1 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">bearing</span><span class="pun">(</span><span class="pln">st_lat</span><span class="pun">,</span><span class="pln"> st_lng</span><span class="pun">,</span><span class="pln"> end_lat</span><span class="pun">,</span><span class="pln"> end_lng</span><span class="pun">);</span><span class="pln">
            bearing1 </span><span class="pun">=</span><span class="pln"> bearing1 </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">180</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> bearing1 </span><span class="pun">+</span><span class="pln"> ang </span><span class="pun">:</span><span class="pln"> bearing1 </span><span class="pun">-</span><span class="pln"> ang</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> dia </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">distance</span><span class="pun">(</span><span class="pln">st_lat</span><span class="pun">,</span><span class="pln"> st_lng</span><span class="pun">,</span><span class="pln"> end_lat</span><span class="pun">,</span><span class="pln"> end_lng</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> fx</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> hyp </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sqrt</span><span class="pun">(</span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">((</span><span class="pln">dia </span><span class="pun">*</span><span class="pln"> fy</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> pos </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">destinationpoint</span><span class="pun">(</span><span class="pln">strt</span><span class="pun">,</span><span class="pln"> bearing1</span><span class="pun">,</span><span class="pln"> hyp</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> mid_lat </span><span class="pun">=</span><span class="pln"> pos</span><span class="pun">.</span><span class="pln">lat</span><span class="pun">,</span><span class="pln"> mid_lng </span><span class="pun">=</span><span class="pln"> pos</span><span class="pun">.</span><span class="pln">lng</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln">it </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> it </span><span class="pun">&lt;=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span><span class="pln"> it </span><span class="pun">+=</span><span class="pln"> resolution</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> points</span><span class="pun">.</span><span class="pln">push</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">.</span><span class="pln">getBezier</span><span class="pun">({</span><span class="pln"> x</span><span class="pun">:</span><span class="pln"> st_lat</span><span class="pun">,</span><span class="pln"> y</span><span class="pun">:</span><span class="pln"> st_lng</span><span class="pun">,</span><span class="pln"> </span><span class="pun">},</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> x</span><span class="pun">:</span><span class="pln"> mid_lat</span><span class="pun">,</span><span class="pln"> y</span><span class="pun">:</span><span class="pln"> mid_lng</span><span class="pun">,</span><span class="pln"> </span><span class="pun">},</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> x</span><span class="pun">:</span><span class="pln"> end_lat</span><span class="pun">,</span><span class="pln"> y</span><span class="pun">:</span><span class="pln"> end_lng</span><span class="pun">,</span><span class="pln"> </span><span class="pun">},</span><span class="pln"> it</span><span class="pun">));</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> points</span><span class="pun">.</span><span class="pln">length </span><span class="pun">-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                path</span><span class="pun">.</span><span class="pln">push</span><span class="pun">({</span><span class="pln"> lat</span><span class="pun">:</span><span class="pln"> points</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">x</span><span class="pun">,</span><span class="pln"> lng</span><span class="pun">:</span><span class="pln"> points</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">y </span><span class="pun">});</span><span class="pln">
            </span><span class="pun">};</span><span class="pln">
            setTimeout</span><span class="pun">(()</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                path</span><span class="pun">.</span><span class="pln">push</span><span class="pun">(</span><span class="pln">strt</span><span class="pun">);</span><span class="pln">
                </span><span class="kwd">return</span><span class="pln"> call</span><span class="pun">(</span><span class="pln">path</span><span class="pun">);</span><span class="pln">
            </span><span class="pun">},</span><span class="pln"> </span><span class="lit">10</span><span class="pun">);</span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        B1 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">t</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> t </span><span class="pun">*</span><span class="pln"> t</span><span class="pun">;</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
        B2 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">t</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">1</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> t</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> t</span><span class="pun">;</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
        B3 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">t</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="lit">1</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> t</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">1</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> t</span><span class="pun">);</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
        getBezier </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">C1</span><span class="pun">,</span><span class="pln"> C2</span><span class="pun">,</span><span class="pln"> C3</span><span class="pun">,</span><span class="pln"> percent</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> pos </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{};</span><span class="pln">
            pos</span><span class="pun">.</span><span class="pln">x </span><span class="pun">=</span><span class="pln"> C1</span><span class="pun">.</span><span class="pln">x </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B1</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> C2</span><span class="pun">.</span><span class="pln">x </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B2</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> C3</span><span class="pun">.</span><span class="pln">x </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B3</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">);</span><span class="pln">
            pos</span><span class="pun">.</span><span class="pln">y </span><span class="pun">=</span><span class="pln"> C1</span><span class="pun">.</span><span class="pln">y </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B1</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> C2</span><span class="pun">.</span><span class="pln">y </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B2</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> C3</span><span class="pun">.</span><span class="pln">y </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">B3</span><span class="pun">(</span><span class="pln">percent</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> pos</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        distance </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">,</span><span class="pln"> lon1</span><span class="pun">,</span><span class="pln"> lat2</span><span class="pun">,</span><span class="pln"> lon2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> R </span><span class="pun">=</span><span class="pln"> </span><span class="lit">6378137</span><span class="pun">;</span><span class="pln"> </span><span class="com">// metres</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> </span><span class="pun">φ</span><span class="lit">1</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">lat1 </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln"> </span><span class="com">// φ, λ in radians</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> </span><span class="pun">φ</span><span class="lit">2</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">lat2 </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> </span><span class="pun">Δφ</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">((</span><span class="pln">lat2 </span><span class="pun">-</span><span class="pln"> lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> </span><span class="pun">Δλ</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">((</span><span class="pln">lon2 </span><span class="pun">-</span><span class="pln"> lon1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> a </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(Δφ</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(Δφ</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(φ</span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(φ</span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(Δλ</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(Δλ</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">2</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> c </span><span class="pun">=</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">atan2</span><span class="pun">(</span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sqrt</span><span class="pun">(</span><span class="pln">a</span><span class="pun">),</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sqrt</span><span class="pun">(</span><span class="lit">1</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> a</span><span class="pun">));</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> d </span><span class="pun">=</span><span class="pln"> R </span><span class="pun">*</span><span class="pln"> c</span><span class="pun">;</span><span class="pln"> </span><span class="com">// in metres</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> d</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        bearing </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(λ</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="pun">φ</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="pun">λ</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="pun">φ</span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> lat1 </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(λ</span><span class="lit">1</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> lat2 </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(λ</span><span class="lit">2</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> dLon </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(φ</span><span class="lit">2</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="pun">φ</span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> y </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">dLon</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">lat2</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> x </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">lat2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">lat2</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">dLon</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">const</span><span class="pln"> brng </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">atan2</span><span class="pun">(</span><span class="pln">y</span><span class="pun">,</span><span class="pln"> x</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="pln">brng </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="lit">180</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">360</span><span class="pun">)</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">360</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">},</span><span class="pln">
        destinationpoint </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">point</span><span class="pun">,</span><span class="pln"> brng</span><span class="pun">,</span><span class="pln"> dist</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            dist </span><span class="pun">=</span><span class="pln"> dist </span><span class="pun">/</span><span class="pln"> </span><span class="lit">6378137</span><span class="pun">;</span><span class="pln">
            brng </span><span class="pun">=</span><span class="pln"> brng </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> lat1 </span><span class="pun">=</span><span class="pln"> point</span><span class="pun">.</span><span class="pln">lat </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">,</span><span class="pln"> lon1 </span><span class="pun">=</span><span class="pln"> point</span><span class="pun">.</span><span class="pln">lng </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI </span><span class="pun">/</span><span class="pln"> </span><span class="lit">180</span><span class="pun">;</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> lat2 </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">asin</span><span class="pun">(</span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">dist</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">dist</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">brng</span><span class="pun">));</span><span class="pln">
            </span><span class="kwd">var</span><span class="pln"> lon2 </span><span class="pun">=</span><span class="pln"> lon1 </span><span class="pun">+</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">atan2</span><span class="pun">(</span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">brng</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">dist</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">),</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">cos</span><span class="pun">(</span><span class="pln">dist</span><span class="pun">)</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">lat1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">sin</span><span class="pun">(</span><span class="pln">lat2</span><span class="pun">));</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> lat</span><span class="pun">:</span><span class="pln"> lat2 </span><span class="pun">*</span><span class="pln"> </span><span class="lit">180</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI</span><span class="pun">,</span><span class="pln"> lng</span><span class="pun">:</span><span class="pln"> lon2 </span><span class="pun">*</span><span class="pln"> </span><span class="lit">180</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><span class="typ">Math</span><span class="pun">.</span><span class="pln">PI </span><span class="pun">};</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
        </span><span class="kwd">var</span><span class="pln"> map</span><span class="pun">,</span><span class="pln">polyline</span><span class="pun">;</span><span class="pln">
        </span><span class="kwd">function</span><span class="pln"> initMap1</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
            map </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> mappls</span><span class="pun">.</span><span class="typ">Map</span><span class="pun">(</span><span class="str">"map"</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                center</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">28.61</span><span class="pun">,</span><span class="pln"> </span><span class="lit">77.23</span><span class="pun">],</span><span class="pln">
                zoomControl</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">,</span><span class="pln">
                location</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">,</span><span class="pln">
            </span><span class="pun">});</span><span class="pln">
            map</span><span class="pun">.</span><span class="pln">addListener</span><span class="pun">(</span><span class="str">'load'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                curveLine</span><span class="pun">({</span><span class="pln">
                    start</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> lng</span><span class="pun">:</span><span class="pln"> </span><span class="lit">77.27428863526279</span><span class="pun">,</span><span class="pln"> lat</span><span class="pun">:</span><span class="pln"> </span><span class="lit">28.550908438470714</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
                    end</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> lng</span><span class="pun">:</span><span class="pln"> </span><span class="lit">77.53557294755876</span><span class="pun">,</span><span class="pln"> lat</span><span class="pun">:</span><span class="pln"> </span><span class="lit">28.660477852756003</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
                    angle</span><span class="pun">:</span><span class="pln"> </span><span class="lit">30</span><span class="pln"> </span><span class="com">// lessthan 45 deegree </span><span class="pln">
                </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    </span><span class="com">//console.log(data);</span><span class="pln">
                    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">polyline</span><span class="pun">)</span><span class="pln"> mappls</span><span class="pun">.</span><span class="pln">remove</span><span class="pun">({</span><span class="pln"> map</span><span class="pun">:</span><span class="pln"> map</span><span class="pun">,</span><span class="pln"> layer</span><span class="pun">:</span><span class="pln"> polyline </span><span class="pun">});</span><span class="pln">
                    polyline </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> mappls</span><span class="pun">.</span><span class="typ">Polyline</span><span class="pun">({</span><span class="pln">
                        map</span><span class="pun">:</span><span class="pln"> map</span><span class="pun">,</span><span class="pln">
                        paths</span><span class="pun">:</span><span class="pln"> data</span><span class="pun">,</span><span class="pln">
                        strokeColor</span><span class="pun">:</span><span class="pln"> </span><span class="str">"#333"</span><span class="pun">,</span><span class="pln">
                        strokeOpacity</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1.0</span><span class="pun">,</span><span class="pln">
                        dasharray</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">],</span><span class="pln">
                        strokeWeight</span><span class="pun">:</span><span class="pln"> </span><span class="lit">2</span><span class="pun">,</span><span class="pln">
                        fitbounds</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">,</span><span class="pln">
                    </span><span class="pun">});</span><span class="pln">
                </span><span class="pun">});</span><span class="pln">
            </span><span class="pun">})</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    </span><span class="tag">&lt;/script&gt;</span><span class="pln">
        </span><span class="tag">&lt;/body&gt;</span><span class="pln">
      </span><span class="tag">&lt;/html&gt;</span><span class="pln">
      </span>
      
      
    
  
Call at Mappls
Request Call Back

Personalisation SDK, by Mappls, is India's first O2O engagement tool that can 3X your customer engagement, retention and conversion.

There's so much that Mappls MapmyIndia can do for your enterprise or individual requirements. Explore our website to learn more or request a callback/email if you'd like us to connect with you.

or