Jquery mobile 用于jQuery Mobile的平移和缩放图像
如果您能为jquery移动web应用提供平移和缩放方面的帮助,我将不胜感激。我有一个建筑平面图的图像,上面有一个图像地图,我希望用户能够通过手机查看,放大和缩小感兴趣的区域并将其平移到视图中。这应该可以做到 这应该能奏效 我解决了OpenLayers的问题,现在图像可以平移和缩放Jquery mobile 用于jQuery Mobile的平移和缩放图像,jquery-mobile,zooming,pan,Jquery Mobile,Zooming,Pan,如果您能为jquery移动web应用提供平移和缩放方面的帮助,我将不胜感激。我有一个建筑平面图的图像,上面有一个图像地图,我希望用户能够通过手机查看,放大和缩小感兴趣的区域并将其平移到视图中。这应该可以做到 这应该能奏效 我解决了OpenLayers的问题,现在图像可以平移和缩放 现在必须弄清楚如何将它与imagemapster结合起来。。(http://www.outsharked.com/imagemapster/)我解决了OpenLayers的问题,图像现在可以平移和缩放 现在必须弄清楚如
现在必须弄清楚如何将它与imagemapster结合起来。。(http://www.outsharked.com/imagemapster/)我解决了OpenLayers的问题,图像现在可以平移和缩放
现在必须弄清楚如何将它与imagemapster结合起来。。(http://www.outsharked.com/imagemapster/)我找到了答案,从OpenLayers示例中获得了所需的一切
<script type="text/javascript">
var map;
function init(){
map = new OpenLayers.Map('map');
var options = {numZoomLevels: 3}
var floorplan = new OpenLayers.Layer.Image(
'Floorplan Map',
'../../temp_photos/sample-floor-plan.jpg',
new OpenLayers.Bounds(-180, -90, 180, 90),
new OpenLayers.Size(275, 190),
options
);
map.addLayer(floorplan);
//Create a Format object
var vector_format = new OpenLayers.Format.GeoJSON({});
//Create a Protocol object using the format object just created
var vector_protocol = new OpenLayers.Protocol.HTTP({
url: '../../controller?action=GET_FLOOR_FEATURES',
format: vector_format
});
//Create an array of strategy objects
var vector_strategies = [new OpenLayers.Strategy.Fixed()];
//Create a vector layer that contains a Format, Protocol, and Strategy class
var vector_layer = new OpenLayers.Layer.Vector('More Advanced Vector Layer',{
protocol: vector_protocol,
strategies: vector_strategies
});
map.addLayer(vector_layer);
//Create and add selectFeature control
var select_feature_control = new OpenLayers.Control.SelectFeature(
vector_layer,
{
multiple: false,
toggle: true,
toggleKey: 'ctrlKey',
multipleKey: 'shiftKey'
}
);
map.addControl(select_feature_control);
//Activate the control
select_feature_control.activate();
//Finally, let's add some events so we can do stuff when the user
// interacts with the features
function selected_feature(event){
//clear out the log's contents
document.getElementById('map_feature_log').innerHTML = '';
//Show the current selected feature (passed in from the event object)
var display_text = 'Clicked on: '
+ '<strong>' + event.feature.attributes.location + '</strong>'
+ ': ' + event.feature.attributes.description + '<hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for(var i=0; i<vector_layer.selectedFeatures.length; i++){
document.getElementById('map_feature_log').innerHTML +=
vector_layer.selectedFeatures[i].attributes.location + ' | ';
}
}
function unselected_feature(event){
var display_text = event.feature.attributes.location + ' unselected!' + '<hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for(var i=0; i<vector_layer.selectedFeatures.length; i++){
document.getElementById('map_feature_log').innerHTML +=
vector_layer.selectedFeatures[i].attributes.location + ' | ';
}
}
//Register the event
vector_layer.events.register('featureselected', this, selected_feature);
vector_layer.events.register('featureunselected', this, unselected_feature);
if(!map.getCenter()){
map.setCenter(new OpenLayers.LonLat(0, 0),1);
}
}
</script>
/**
*
*@作者克里斯蒂娜
*/
公共类GetFloorFeatures实现操作{
private static final int MAX_INACTIVE_INTERVAL = 900; // 15 minutes
private String view;
@Override
public boolean execute(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
HttpSession session = req.getSession(true);
System.out.println("------------ In GetFloorFeatures");
session.setMaxInactiveInterval(MAX_INACTIVE_INTERVAL);
view = "pages/maps/displayFloorFeatures.jsp";
return true;
}
@Override
public String getView() {
return view;
}
@Override
public Object getModel() {
return null;
}
}
数据在jsp文件中硬编码,但最终将通过数据库查询生成:
<%@page contentType="application/json" pageEncoding="UTF-8"%>
<% response.setContentType("application/json");
//harcoded now, later will call database query to retrieve features for this floor
String floorFeatureVectors = "{\"type\": \"FeatureCollection\",\"features\": [{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_84\", \"properties\":{\"location\": \"Telecom Lab\",\"description\": \"Stand back, I'm going to try science!\"}, \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[9, -52.342105263158], [9.4736842105263, -79.815789473684], [40.263157894737, -78.868421052632], [43.105263157895, -78.394736842105], [44.526315789474, -51.394736842105], [9, -52.342105263158]]]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}},"
+ "{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_85\", \"properties\":{\"location\": \"MUSIC lab\",\"description\": \"Laboratory of Distributed Multimedia Information Systems and Applications \"}, \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[-113.21052631579, 4.9736842105263], [-113.68421052632, -11.605263157895], [-76.263157894737, -13.026315789474], [-76.263157894737, -1.1842105263158], [-93.315789473684, -0.71052631578947], [-93.789473684211, 4.0263157894737], [-113.21052631579, 4.9736842105263]]]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}},"
+ "{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_86\", \"properties\":{\"location\": \"Main Entrance Science Building\",\"description\": \"Caffeteria \"}, \"geometry\":{\"type\":\"Point\", \"coordinates\":[-8.0526315789474, 36.710526315789]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}}"
+ "]}";%><%=floorFeatureVectors%>
我找到了答案,从OpenLayers示例中获得了我所需要的一切
<script type="text/javascript">
var map;
function init(){
map = new OpenLayers.Map('map');
var options = {numZoomLevels: 3}
var floorplan = new OpenLayers.Layer.Image(
'Floorplan Map',
'../../temp_photos/sample-floor-plan.jpg',
new OpenLayers.Bounds(-180, -90, 180, 90),
new OpenLayers.Size(275, 190),
options
);
map.addLayer(floorplan);
//Create a Format object
var vector_format = new OpenLayers.Format.GeoJSON({});
//Create a Protocol object using the format object just created
var vector_protocol = new OpenLayers.Protocol.HTTP({
url: '../../controller?action=GET_FLOOR_FEATURES',
format: vector_format
});
//Create an array of strategy objects
var vector_strategies = [new OpenLayers.Strategy.Fixed()];
//Create a vector layer that contains a Format, Protocol, and Strategy class
var vector_layer = new OpenLayers.Layer.Vector('More Advanced Vector Layer',{
protocol: vector_protocol,
strategies: vector_strategies
});
map.addLayer(vector_layer);
//Create and add selectFeature control
var select_feature_control = new OpenLayers.Control.SelectFeature(
vector_layer,
{
multiple: false,
toggle: true,
toggleKey: 'ctrlKey',
multipleKey: 'shiftKey'
}
);
map.addControl(select_feature_control);
//Activate the control
select_feature_control.activate();
//Finally, let's add some events so we can do stuff when the user
// interacts with the features
function selected_feature(event){
//clear out the log's contents
document.getElementById('map_feature_log').innerHTML = '';
//Show the current selected feature (passed in from the event object)
var display_text = 'Clicked on: '
+ '<strong>' + event.feature.attributes.location + '</strong>'
+ ': ' + event.feature.attributes.description + '<hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for(var i=0; i<vector_layer.selectedFeatures.length; i++){
document.getElementById('map_feature_log').innerHTML +=
vector_layer.selectedFeatures[i].attributes.location + ' | ';
}
}
function unselected_feature(event){
var display_text = event.feature.attributes.location + ' unselected!' + '<hr />';
document.getElementById('map_feature_log').innerHTML = display_text;
//Show all the selected features
document.getElementById('map_feature_log').innerHTML += 'All selected features: ';
//Now, loop through the selected feature array
for(var i=0; i<vector_layer.selectedFeatures.length; i++){
document.getElementById('map_feature_log').innerHTML +=
vector_layer.selectedFeatures[i].attributes.location + ' | ';
}
}
//Register the event
vector_layer.events.register('featureselected', this, selected_feature);
vector_layer.events.register('featureunselected', this, unselected_feature);
if(!map.getCenter()){
map.setCenter(new OpenLayers.LonLat(0, 0),1);
}
}
</script>
/**
*
*@作者克里斯蒂娜
*/
公共类GetFloorFeatures实现操作{
private static final int MAX_INACTIVE_INTERVAL = 900; // 15 minutes
private String view;
@Override
public boolean execute(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
HttpSession session = req.getSession(true);
System.out.println("------------ In GetFloorFeatures");
session.setMaxInactiveInterval(MAX_INACTIVE_INTERVAL);
view = "pages/maps/displayFloorFeatures.jsp";
return true;
}
@Override
public String getView() {
return view;
}
@Override
public Object getModel() {
return null;
}
}
数据在jsp文件中硬编码,但最终将通过数据库查询生成:
<%@page contentType="application/json" pageEncoding="UTF-8"%>
<% response.setContentType("application/json");
//harcoded now, later will call database query to retrieve features for this floor
String floorFeatureVectors = "{\"type\": \"FeatureCollection\",\"features\": [{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_84\", \"properties\":{\"location\": \"Telecom Lab\",\"description\": \"Stand back, I'm going to try science!\"}, \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[9, -52.342105263158], [9.4736842105263, -79.815789473684], [40.263157894737, -78.868421052632], [43.105263157895, -78.394736842105], [44.526315789474, -51.394736842105], [9, -52.342105263158]]]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}},"
+ "{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_85\", \"properties\":{\"location\": \"MUSIC lab\",\"description\": \"Laboratory of Distributed Multimedia Information Systems and Applications \"}, \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[-113.21052631579, 4.9736842105263], [-113.68421052632, -11.605263157895], [-76.263157894737, -13.026315789474], [-76.263157894737, -1.1842105263158], [-93.315789473684, -0.71052631578947], [-93.789473684211, 4.0263157894737], [-113.21052631579, 4.9736842105263]]]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}},"
+ "{\"type\":\"Feature\", \"id\":\"OpenLayers.Feature.Vector_86\", \"properties\":{\"location\": \"Main Entrance Science Building\",\"description\": \"Caffeteria \"}, \"geometry\":{\"type\":\"Point\", \"coordinates\":[-8.0526315789474, 36.710526315789]}, \"crs\":{\"type\":\"OGC\", \"properties\":{\"urn\":\"urn:ogc:def:crs:OGC:1.3:CRS84\"}}}"
+ "]}";%><%=floorFeatureVectors%>
我一直在研究同一个问题,办公室的办公桌平面图应根据办公桌的状态(空的、已分配的、热坐的等)以不同的颜色显示
除此之外,如果用户单击桌面,则应显示分配的同事/员工的详细信息
上述要求是使用image mapster jquery插件实现的
此外,还应提供缩放和平移。对于缩放和平移,我发现gzoom插件最适合我的要求。但是,当与image mapster插件一起使用时,它并没有像预期的那样工作
非常感谢您在这方面的帮助。我一直在解决同一个问题,办公室的办公桌平面图应根据办公桌的状态(空的、已分配的、热坐的等)以不同的颜色显示
除此之外,如果用户单击桌面,则应显示分配的同事/员工的详细信息
上述要求是使用image mapster jquery插件实现的
此外,还应提供缩放和平移。对于缩放和平移,我发现gzoom插件最适合我的要求。但是,当与image mapster插件一起使用时,它并没有像预期的那样工作
非常感谢您在这方面的帮助。谢谢。在发布我的问题之前,我开始玩Photoswip。到目前为止,我遇到了各种各样的问题。我希望图像能够在放置的div中自行平移和缩放,我不希望jquery和jquery mobile需要更多的代码。我正在使用imagemapster使我的图像区域具有交互性,我不想失去该功能…谢谢。在发布我的问题之前,我开始玩Photoswip。到目前为止,我遇到了各种各样的问题。我希望图像能够在放置的div中自行平移和缩放,我不希望jquery和jquery mobile需要更多的代码。我正在使用imagemapster使我的图像区域具有交互性,我不想失去该功能…您好!我用OpenLayers解决了同样的问题,最后我放弃了imagemapster。我建议你试试看。下面是一个你可以拥有的所有弹出窗口的例子:你好!我用OpenLayers解决了同样的问题,最后我放弃了imagemapster。我建议你试试看。以下是您可以拥有的所有弹出窗口的示例: