导航:首页 > 编程语言 > 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图片标注点相关的资料

热点内容
pps缓存文件怎么删除 浏览:10
家里网络在用怎么检测 浏览:419
克拉漫播下载的文件名 浏览:417
压缩好的文件哪里找 浏览:831
百度网盘怎样上传文件夹 浏览:320
java发展是 浏览:892
程序编程结束还要做什么 浏览:778
pcb打版文件有哪些 浏览:39
网络原来ip地址忘记了怎么办 浏览:142
iphone6s微信密码设置 浏览:810
java将数字转换成字母 浏览:854
c盘中的哪些是系统文件夹 浏览:668
分布式服务如何跨库统计数据 浏览:829
力控转发数据客户端模式如何建立 浏览:200
怎么样让自己的网站不被别人看到 浏览:711
编程扩展效果如何 浏览:335
荣耀畅玩手环同步qq 浏览:475
怎么向sql中添加数据库 浏览:596
录歌失败重启app什么意思 浏览:522
压缩文件包怎么在微信发送 浏览:432

友情链接