導航:首頁 > 編程語言 > js圖片標注點

js圖片標注點

發布時間:2023-09-25 18:11:01

1. c# 怎麼可圖片添加標注!

javascript和AJAX做,當頁面某區域感知到滑鼠進入後,就執行響應的js函數,JS函數通過AJAX從伺服器得到相應數據,發送到客戶端,在回調函數中,你可以寫JS,彈出一個動態生成的透明DIV,這個DIV內部有一個氣泡狀的圖片(或者設置DIV的背景圖片為氣泡圖),在DIV內顯示的文字,就是AJAX傳過來的數據。

2. SuperMap怎麼用JavaScript在地圖上標注文字

<p><!DOCTYPE html>
<html xmlns="<a target="_blank" href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="libs/SuperMap.Include.js"></script>
<script type="text/<a href="http://lib.csdn.net/base/javascript" class="replace_word" title="JavaScript知識庫" target="_blank" style="color:#df3434; font-weight:bold;">JavaScript</a>">
var map, layer, popup;
var featuresLayer, drawLine, drawPoint, drawPolygon, selectDrawFeature;
var drawFeatureStyle = {
strokeColor: null,
strokeWidth: null,
strokeOpacity: null,
pointRadius: 6,
fillColor: null,
fillOpacity: null,
cursor: "pointer"
};//定義要添加要素的樣式
var selectStyle={
strokeColor: "#0099FF",
strokeWidth: 2,
pointerEvents: "visiblePainted",
fillColor: "#FF8247",
fillOpacity: 0.4,
pointRadius: 6,
label: "",
fontSize: 14,
fontWeight: "normal",
cursor: "pointer"
};// 點擊添加的元素之後的樣式
// 設置訪問的GIS服務地址
var url = "<a target="_blank" href="http://localhost:8090/iserver/services/map-ChinaTestWorkPlace/rest/maps/ChinaTest">http://localhost:8090/iserver/services/map-ChinaTestWorkPlace/rest/maps/ChinaTest</a>";
function GetMap() {
// 創建地圖對象
map = new SuperMap.Map("map");
//control = new SuperMap.Control.MousePosition(); //該控制項顯示滑鼠移動時,所在點的地理坐標。
//map.addControl(control); //添加控制項
featuresLayer = new SuperMap.Layer.Vector("<a target="_blank" href="mailto:test!@#');//">test!@#");//</a> test!@# 是圖層的name屬性
drawLine = new SuperMap.Control.DrawFeature(featuresLayer, SuperMap.Handler.Path, { multi: true });
drawLine.events.on({ "featureadded": drawCompleted });
drawPoint = new SuperMap.Control.DrawFeature(featuresLayer, SuperMap.Handler.Point, { multi: true });
drawPoint.events.on({ "featureadded": drawCompleted });
drawPolygon = new SuperMap.Control.DrawFeature(featuresLayer, SuperMap.Handler.Polygon, { multi: true });
drawPolygon.events.on({ "featureadded": drawCompleted });
map.addControls([drawLine, drawPoint, drawPolygon]);
map.addLayer(featuresLayer);
// 創建圖層對象
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" });
layer.events.on({ "layerInitialized": AddLayer });
}
// 載入圖層
function AddLayer() {
// 向Map添加圖層
map.addLayer(layer);
map.setCenter(new SuperMap.LonLat(116.409749, 39.912344), 1);</p><p> //這里添加兩種事件方式點擊事件和mouseover事件,都可以實現,這里屏蔽掉單擊事件。
// 添加單擊事件
//selectDrawFeature = new SuperMap.Control.SelectFeature(featuresLayer, {
// onSelect: openWindow,
// onUnselect: unfeatueSelect
//});
//selectDrawFeature.repeat = true;
//selectDrawFeature.toggle = true;
//map.addControl(selectDrawFeature);
//selectDrawFeature.activate();
//添加滑鼠mouseover 事件
selectDrawFeature = new SuperMap.Control.SelectFeature(featuresLayer, {
onSelect: openWindow,
onUnselect: unfeatueSelect,
hover:true
});
map.addControl(selectDrawFeature);
selectDrawFeature.activate();
}
function drawFeature(type) {
var fillColor = document.getElementById("color1").value;
var strokeColor = document.getElementById("color2").value;
var opacity = document.getElementById("txtOpacity").value;
var lineWidth = document.getElementById("txtLineWidth").value;
drawFeatureStyle.fillColor = fillColor;
drawFeatureStyle.strokeColor = strokeColor;
drawFeatureStyle.strokeWidth = lineWidth;
drawFeatureStyle.strokeOpacity = opacity;
drawFeatureStyle.fillOpacity = opacity;
if (type === "point") {
drawPoints();
}
else if (type === "line") {
drawLines();
}
else if (type === "polygon") {
drawPolygons();
}
}
function drawPoints() {
featuresLayer.style = drawFeatureStyle;
drawPoint.activate();
}
function drawLines() {
featuresLayer.style = drawFeatureStyle;
drawLine.activate();
}
function drawPolygons() {
featuresLayer.style = drawFeatureStyle;
drawPolygon.activate();
}
function drawCompleted(drawGeometryArgs) {
drawLine.deactivate();
drawPoint.deactivate();
drawPolygon.deactivate();
}
function clearAll() {
featuresLayer.removeAllFeatures();
}
function openWindow(feature) {
var name;
if (feature.geometry.CLASS_NAME == "SuperMap.Geometry.MultiPoint") {
name = "標注點";
} else if (feature.geometry.CLASS_NAME == "SuperMap.Geometry.MultiPolygon") {
name = "標注面"
} else {
name = "標注線"
}
popup = new SuperMap.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
null,
name,
null, true);
feature.popup = popup;
popup.panMapIfOutOfView = true;
map.addPopup(popup);
feature.style = selectStyle;
featuresLayer.redraw();
featuresLayer.setOpacity(0.5);
}
function unfeatueSelect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;</p><p> feature.style = drawFeatureStyle;
featuresLayer.redraw();
}
</script>
</head>
<body onload="GetMap()">
<div>
<img alt="點" src="resource/controlImages/drawPoint.png" onclick="drawFeature('point')" />
<img alt="線" src="resource/controlImages/drawLine.png" onclick="drawFeature('line')" />
<img alt="面" src="resource/controlImages/drawRegion.png" onclick="drawFeature('polygon')" />
<img alt="清除" src="resource/controlImages/eraser.png" onclick="clearAll()" />
</div>
<div>
<table style="font-size: 12px">
<tr>
<td>
填充顏色:
</td>
<td>
<input type="text" size="10" id="color1" maxlength="7" name="rgb1" value="#FFFFFF"
onclick="showColorPicker(this, document.forms[0].rgb1)"/>
</td>
</tr>
<tr>
<td>
填充透明度:
</td>
<td>
<select id="txtOpacity">
<option value="0.1">0.1</option>
<option value="0.2">0.2</option>
<option value="0.3">0.3</option>
<option value="0.4">0.4</option>
<option value="0.5" selected="selected">0.5</option>
<option value="0.6">0.6</option>
<option value="0.7">0.7</option>
<option value="0.8">0.8</option>
<option value="0.9">0.9</option>
<option value="1.0">1.0</option>
</select>
</td>
</tr>
<tr>
<td>
線寬:
</td>
<td>
<input type="text" id="txtLineWidth" style="width: 50px" value="2" />
</td>
</tr>
<tr>
<td>
邊線顏色:
</td>
<td>
<input type="text" size="10" id="color2" maxlength="7" name="rgb2" value="#FF0000"
onclick="showColorPicker(this, document.forms[0].rgb2)"/>
</td>
</tr>
</table></p><p>
</div>
<div id="map" style="height: 640px; width: 720px; border: 1px solid red; margin-left: auto; margin-right: auto;"></div>
</body>
</html>
</p>

3. javascript怎麼實現類似百度地圖的標記效果啊

詳情訪問該鏈接:http://developer..com/map/jsdemo.htm#c1_1

js代碼如下:
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
var marker1 = new BMap.Marker(new BMap.Point(116.384, 39.925)); // 創建標注
map.addOverlay(marker1); // 將標注添加到地圖中

//創建信息窗口
var infoWindow1 = new BMap.InfoWindow("普通標注");
marker1.addEventListener("click", function(){this.openInfoWindow(infoWindow1);});

//創建小狐狸
var pt = new BMap.Point(116.417, 39.909);
var myIcon = new BMap.Icon("fox.gif", new BMap.Size(300,157));
var marker2 = new BMap.Marker(pt,{icon:myIcon}); // 創建標注
map.addOverlay(marker2); // 將標注添加到地圖中

//讓小狐狸說話(創建信息窗口)
var infoWindow2 = new BMap.InfoWindow("<p style='font-size:14px;'>哈哈,你看見我啦!我可不常出現哦!</p><p style='font-size:14px;'>趕快查看源代碼,看看我是如何添加上來的!</p>");
marker2.addEventListener("click", function(){this.openInfoWindow(infoWindow2);});

4. three.js 給模型添加標注

1. 需要有一個被選擇的mesh,通過raycaster獲取

2. 創建先和一個平面

3. 將線和標注的面放在獲取的mesh上

var mouse =new THREE.Vector2();

var raycaster =new THREE.Raycaster();

mouse.x = (event.clientX / domElement.width) *2 -1;

mouse.y = -(event.clientY / domElement.height) *2 +1;

raycaster.setFromCamera(mouse, camera);

var intersects = raycaster.intersectObjects(scene.children, false); // 

selectedObject = intersects[0].object; // 被選中的標注對象

// 

var startP,endP;// 這里也是通過raycaster獲取到的

var color = parameters.hasOwnProperty("color") ? parameters.color :0x0000ff;

 var lineMat =new THREE.LineBasicMaterial({

        "color": 0xff0000

});

var lineGeo =new THREE.Geometry();

lineGeo.vertices.push(startPos);

lineGeo.vertices.push(endPos);

var line =new THREE.Line(lineGeo, lineMat);

// 初始化一個sprite,這是一個始終面向相機的平面,

var sprite = new textSprite(這並不是一個構造函數,不想寫那麼多,自行去官網查看)

.......

sprite.scale.set(_spriteScale, _spriteScale, _spriteScale); // 設置的是sprite的大小派脊野

selectedObject.add(line); // 添加

line.worldToLocal(_endPos); // 設置點

sprite.position.(_endPos); // 設置sprite的位置

line.add(sprite); 添加並進行關聯

注: sprite可以用於進行塵喊標注熱點等操作,具體實現較為簡單,同時因為也算是mesh,所以sprite可以設置texture,使用圖片作為背景等,也可以野帶把一個canvas,把需要的文字圖片等都加入進來.

5. 百度地圖api js版 多標注如何在地圖上按照合適的縮放比例全部展示出來 請教了

/* 地圖上定位點 */
function anchorPoint(markerArr){
var point = new Array(); //標注點經緯信息
var marker = new Array(); //存放標注點對象
var info = new Array(); //存放提示信息窗口對象的數組
var searchInfoWindow =new Array();//存放檢索信息窗口對象的數組

for (var i = 0; i < markerArr.length; i++) {
var lng = markerArr[i].lng;
var lat = markerArr[i].lat;
point[i] = new BMap.Point(lng, lat);
marker[i] = new BMap.Marker(point[i]);

if(markerArr[i].parkEmptyCount >= 20 && markerArr[i].parkEmptyUpdateDate != null){
var icons = MAT_HOST + "/public/images/green.png"; //圖片路徑
var icon = new BMap.Icon(icons, new BMap.Size(24, 26),{
anchor: new BMap.Size(10, 25),
infoWindowAnchor: new BMap.Size(10, 0)
}); //顯示圖標大小
marker[i].setIcon(icon);//設置標簽的圖標為自定義圖標
marker[i].disableMassClear();
map.addOverlay(marker[i]);//將標簽添加到地圖中去
}
if(markerArr[i].parkEmptyCount > 0 && markerArr[i].parkEmptyCount < 20 && markerArr[i].parkEmptyUpdateDate != null){
var icons = MAT_HOST + "/public/images/orange.png";
var icon = new BMap.Icon(icons, new BMap.Size(24, 26),{
anchor: new BMap.Size(10, 25),
infoWindowAnchor: new BMap.Size(10, 0)
});
marker[i].setIcon(icon);
marker[i].disableMassClear();
map.addOverlay(marker[i]);
}
if(markerArr[i].parkEmptyCount == 0 || markerArr[i].parkEmptyUpdateDate == null){
var icons = MAT_HOST + "/public/images/red.png";
var icon = new BMap.Icon(icons, new BMap.Size(24, 26),{
anchor: new BMap.Size(10, 25),
infoWindowAnchor: new BMap.Size(10, 0)
});
marker[i].setIcon(icon);
marker[i].disableMassClear();
map.addOverlay(marker[i]);
}

var parkEmptyUpdateDate = markerArr[i].parkEmptyUpdateDate;
parkEmptyUpdateDate = $.dateFormat({date:parkEmptyUpdateDate});

if(parkEmptyUpdateDate == ""){
markerArr[i].parkEmptyCount = "未知";
}

info[i] = '<div style="padding:5px;font-size:12px;line-height:16px;">';
info[i] += ' <p style="padding:4px 0;">地址:'+markerArr[i].addr+'</p>';
info[i] += ' <p style="padding:4px 0;">空車位個數:' + markerArr[i].parkEmptyCount + '</p>';
if(parkEmptyUpdateDate != ""){
info[i] += ' <p style="padding:4px 0;">最後更新時間:' + parkEmptyUpdateDate;
}
info[i] += '</div>';

searchInfoWindow[i] = new BMapLib.SearchInfoWindow(map, info[i], {
title: '<strong>'+markerArr[i].unitName+'</strong>', //標題
width:300, //寬度
panel:"panel", //檢索結果面板
enableAutoPan : true, //自動平移
searchTypes:[
BMAPLIB_TAB_SEARCH, //周邊檢索
BMAPLIB_TAB_TO_HERE, //到這里去
BMAPLIB_TAB_FROM_HERE //從這里出發
]
});

//滑鼠移上事件
marker[i].addEventListener("mouseover", (function(k){
return function(){
searchInfoWindow[k].open(marker[k]); //在marker上打開檢索信息窗口
}
})(i));

map.addEventListener("click", (function(k){
return function(){
searchInfoWindow[k].close(marker[k]); //在marker上打開檢索信息窗口
}
})(i));
}
}
循環列印就行了

閱讀全文

與js圖片標注點相關的資料

熱點內容
視頻課程學習有哪些app 瀏覽:375
鐵模編程怎麼學 瀏覽:298
數學網路研修研究問題有哪些 瀏覽:677
stl文件怎麼列印 瀏覽:427
json格式變數寫法 瀏覽:68
廣州寄文件去吉林多少錢 瀏覽:254
蘋果APP文件夾創建 瀏覽:903
黃米是什麼app 瀏覽:417
word如何插入一個新文件夾 瀏覽:357
word文件夾前面有個符號 瀏覽:350
把word轉換成語音 瀏覽:220
linuxfile文件 瀏覽:454
如何用網路打普通電話 瀏覽:463
linux進程打開的文件 瀏覽:134
新購u盤無法儲存文件 瀏覽:553
5s要不要升級ios93 瀏覽:926
小米手機助手怎麼關閉自動升級 瀏覽:24
外星人能不能升級到win10系統盤 瀏覽:652
加入java信任站點 瀏覽:486
好用的急救知識app 瀏覽:524

友情鏈接