<?xml version="1.0"?> <points> <point> <lat>38.12</lat> <long>-81.25</long> </point> <point> <lat>39.23</lat> <long>-81.25</long> </point> </Points>
1) Is it possible to bind info Window mentioned http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/widget_popupfl.html on click to show some fields from the same node where lat lng is stored. 2) Since my data is coming from sql server and converted to xml my second question is that is it posible to display line feature and polygon feature ?
What happens when you use that url?
Glad to demonstrate it's a piece of cake in JS as well .
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> points from json^H^H^H^H xml! </title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #map{ padding:0; } </style> <script type="text/javascript">var djConfig = {parseOnLoad: true};</script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); var map; function init() { var initExtent = new esri.geometry.Extent({"xmin":-13632648,"ymin":4542594,"xmax":-13621699,"ymax":4546875,"spatialReference":{"wkid":102100}}); map = new esri.Map("map",{extent:initExtent}); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); var resizeTimer; dojo.connect(map, 'onLoad', function(theMap) { dojo.connect(dijit.byId('map'), 'resize', function() { clearTimeout(resizeTimer); resizeTimer = setTimeout( function() { map.resize(); map.reposition(); }, 500); }); getXML(); }); } function getXML() { dojo.xhrGet({ 'url': 'points.xml', 'content': {}, 'handleAs': 'xml', 'load': displayPoints, 'error': error }); } function displayPoints(pts) { console.log('success: ', pts); xmlpts = pts; var sym = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0]), 1), new dojo.Color([255,0,0,0.5])); dojo.forEach(dojo.query('point', pts), function(pt) { // might be a cleaner way to do this with dojox.xml.parser but this works so... var lat = parseFloat(dojo.query('lat', pt)[0].childNodes[0].data); var lng = parseFloat(dojo.query('long', pt)[0].childNodes[0].data); var geom = esri.geometry.geographicToWebMercator(new esri.geometry.Point(lng, lat, new esri.SpatialReference({wkid: 4326}))); var graphic = new esri.Graphic(geom, sym); map.graphics.add(graphic); }); // zoom to our newly added graphics map.setExtent(esri.graphicsExtent(map.graphics.graphics), true); } function error(error) { console.log('failed: ', error); } dojo.addOnLoad(init); </script> </head> <body class="claro"> <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%; margin: 0;"> <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden;"> </div> </div> </body> </html>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.