2017-05-05 66 views
0

我剛剛創建了一個ASPX項目,並希望集成傳單地圖。如何使用傳單地圖與aspx?

我以前用過HTML頁面的小冊子,但現在ASPX要求我把所有內容都放在<asp:content>標籤中。

我的代碼

<asp:Content ID="MapPage" ContentPlaceHolderID="MainContent" runat="server"> 
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" 
    integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" 
    crossorigin=""/> 

    <script src="https://unpkg.com/[email protected]/dist/leaflet.js" 
    integrity="sha512-A7vV8IFfih/D732iSSKi20u/ooOfj/AGehOKq0f4vLT1Zr2Y+RX7C+w8A1gaSasGtRUZpF/NZgzSAu4/Gc41Lg==" 
    crossorigin=""></script> 


    <div id="mapid" style="height:100px; width:100px;"></div> 

</asp:Content> 

我把鏈接和腳本標籤從http://leafletjs.com/examples/quick-start/

他們的教程...此外,VS17說HTML5不承認crossoriginintegrity領域......任何建議?

回答

0

你可以試試這個,這對我有用。

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" 
AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" 
Inherits="WebApplication1.WebForm3" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" 
runat="server"> 

<meta charset="utf-8" /> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 

<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" /> 

    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-07I2e+7D8p6he1SIM+1twR5TIrhUQn9+I6yjqD53JQjFiMf8EtC93ty0/5vJTZGF8aAocvHYNEDJajGdNx1IsQ==" crossorigin=""/> 
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-A7vV8IFfih/D732iSSKi20u/ooOfj/AGehOKq0f4vLT1Zr2Y+RX7C+w8A1gaSasGtRUZpF/NZgzSAu4/Gc41Lg==" crossorigin=""></script> 




<body> 



<div id="mapid" style="width: 600px; height: 400px;"></div> 
<script> 

var mymap = L.map('mapid').setView([51.505, -0.09], 13); 

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { 
    maxZoom: 18, 
    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + 
     '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 
     'Imagery © <a href="http://mapbox.com">Mapbox</a>', 
    id: 'mapbox.streets' 
}).addTo(mymap);