POST
|
Hi code looks okay, i get mine working like this function zoomToLocation(location) {
// use this if basemap is WGS84 --- var pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(location.coords.longitude, location.coords.latitude));
//otherwise, use this stuff below - basically we make a new point with the geolocated coordinates and reproject it, but to do so, you make the point
//first and specify it's originating spatial reference so then you can reproject it to your own wkid
var pt = new esri.geometry.Point(location.coords.longitude, location.coords.latitude, new esri.SpatialReference({wkid: 4236})); //don't forget to specify the originating wkid (in this case from the GPS/Geolocation)
var outSR = new esri.SpatialReference({ wkid: 27700});
gsvc.project([ pt ], outSR, function(projectedPoints) {
pt = projectedPoints[0];
map.centerAndZoom(pt, 12);
//add graphic at current location - if graphic exists just move it
if (!graphic) {
addGraphic(pt);
}
else { //move the graphic if it already exists
graphic.setGeometry(pt);
}
map.centerAt(pt);
})
} this converts from web mecator to british national grid. I set a global var - var gsvc = null; then specify the service like you do gsvc = new esri.tasks.GeometryService("local server"); Let us know how you get on, you should be getting some error with firebug etc.
... View more
11-15-2012
11:45 PM
|
0
|
0
|
295
|
POST
|
Looks fine. Where are you calling this? Inside the init function? Do you have any custom CSS for map? Also, not ment to offend but theMap - is it valid for your application and not copied from code example? cheers
... View more
11-14-2012
04:48 AM
|
0
|
0
|
383
|
POST
|
Easiest way i would do it would be an if/else statement based on the json results being blank when you click on the map with no info. There is probably an easier way to do it. Hope this helps.
... View more
11-14-2012
03:56 AM
|
0
|
0
|
112
|
POST
|
wierd, i guess that you tried that on your local machine... Can you try the html5 one aswell and see if you get similar results? http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/exp_geolocate.html
... View more
11-05-2012
06:28 AM
|
0
|
0
|
409
|
POST
|
Hi Okay, try the geometry reproject service here - http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project see if the results when you reproject to 102100 are better suited try testing with these new co ords hard coded just to see if its where it should be, thats the only thing i can think of that there is a mismatched between the spatial ref's inSR = 3443 outSR = 102100 Geometries X, Y Sorry i cant be of anymore help.
... View more
11-02-2012
03:46 PM
|
0
|
0
|
409
|
POST
|
okay got it. Are the returned co ords and the basemap in the same spatial ref? try creating a point for it to go to ie: function showResults(candidates) {
var candidate = candidates[0];
..............
geom = candidate.location;
var point = new esri.geometry.Point([geom], new esri.SpatialReference({
wkid: YOUR WKID
}));
map.centerAndZoom(point, 16); If you can output the results of your geom i will check to ensure everything is there. I had similar issues and it was down to not specifying the spatial ref or the spatial ref of the basemap was incorrect with the spatial ref of the address results, you might need to run a geometry job to change spatial ref but if you can let me know your basemap spatial ref and the address locator spatial ref that will clear that up. cheers
... View more
11-02-2012
08:40 AM
|
0
|
0
|
409
|
POST
|
Hi What's on your geom parameter? Try setting your geom with a wkid (matching the basemap)...something like this: var point = new esri.geometry.Point([x, y], new esri.SpatialReference({
wkid: 27700
}));
console.log("Zooming to location...", point, zoomLevel);
map.centerAndZoom(point, zoomLevel);
console.log("Zoom complete");
... View more
11-02-2012
07:48 AM
|
0
|
0
|
409
|
POST
|
Hi The API always bases the slider and scales available based on the first tiled map service added to the code. We got around this by setting the best scales that matched all the mapping we had. You can change this by hard coding levels of detail - http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/map_customtilelevels.html I have seen something in another API that actually changes the silder when you switch basemaps but i dont think this functionality is available currently (i might be wrong though but when i looked for it is wasnt about!) Hope this helps
... View more
10-29-2012
03:38 PM
|
0
|
0
|
153
|
POST
|
Im unsure on arcgis online, true is i never use it as we tend to develop inhouse and we have a esri uk product that is based on the JSAPI so im unsure on what is being done in the code. Could you not do something like this?
//define a popup template
var popupTemplate = new esri.dijit.PopupTemplate({
title: "{AId}",
fieldInfos: [
{fieldName: "AEID", visible: true, label:"EID"},
{fieldName: "AName", visible:true, label:"Name"},
{fieldName: "geoPoint.x", visible:true, label:"Xcoord"},
{fieldName: "geoPoint.y", visible:true, label:"Ycoord"},
{fieldName: "AIndex", visible:true, label:"AssetIndex"}
],
});
//create a feature layer based on the feature collection
var featureLayer = new esri.layers.FeatureLayer("YOUR SERVER HERE, CAN BE OTHER TYPES OF LAYERS", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT, //DEPENDS WHAT YOU WANT? MIGHT NOT BE NEEDED AS A DYNAMIC SERVICE ETC
infoTemplate: popupTemplate,
outFields: ["*"]
}); If you could post some more code i will have a look.
... View more
10-29-2012
03:30 PM
|
0
|
0
|
286
|
POST
|
Hi Just to get this right, if you specify a hard coded title ie - map.infoWindow.setTitle("Results"); you still dont get any title?
... View more
10-29-2012
07:35 AM
|
0
|
0
|
286
|
POST
|
Hi I would like to use two info windows, both displaying different results. One will be for the address search results (once the map zoom's into the location) //the info window for the address details after zooming to location on map
function buildAddWindow(addr, pt) {
var replacement = ", ";
var addrTrim = addr.replace(/\|LOCATOR_SEPARATOR\|/g, replacement);
console.log(addrTrim);
var addInfoTemplate = new esri.InfoTemplate(addrTrim);
map.infoWindow.setTitle("Address");
map.infoWindow.setContent("Address : " + addrTrim);
map.infoWindow.resize(250, 175);
map.infoWindow.show(pt, esri.dijit.InfoWindow.ANCHOR_LOWERRIGHT);
}; The other is for the identify results its quite complex so this is just a section of where it creates the info window: // identify and retrieve layers from the rest endpoint
function setUpIdentify(layers) {
//when user clicks on map, call doIndentify()
//map.graphics.clear();
dojo.connect(map, "onClick", doIdentify);
console.log("Setting up identify");
identifyTask = new esri.tasks.IdentifyTask("http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer");
identifyParams = new esri.tasks.IdentifyParameters();
//identifyParams.spatialReference = new esri.SpatialReference({ wkid: 27700});
identifyParams.tolerance = 5;
identifyParams.returnGeometry = true;
identifyParams.layerIds = layers;
//console.log(layers);
//identifyParams.layerIds = visible;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
//create info window
//var ideninfoTemplate = new esri.InfoTemplate();
map.infoWindow.resize(480, 300);
map.infoWindow.setContent(dijit.byId("tabs").domNode);
map.infoWindow.setTitle("Identify Results");
}
function doIdentify(evt) {
console.log("Do Identify");
map.graphics.clear();
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
var mapLevel = map.getLevel();
if (mapLevel >=7 ) {
identifyTask.execute(identifyParams, function(idResults) { addToMap(idResults, evt); });
}else {
alert("This has returned too many results.\n\nPlease zoom in or search for an address to narrow your selection");
}
};
I am having issues when once a user has done an address search and the map has zoomed into the location and shown the address details in the info window. If i then click on a item to run the identify task i get an error relating to the following function: // add results to info window - custom to this application each layer results are manually configured here
function addToMap(idResults, evt) {
layer7results = { displayFieldName: null, features: [] };
layer3results = { displayFieldName: null, features: [] };
layer4results = { displayFieldName: null, features: [] };
layer2results = { displayFieldName: null, features: [] };
layer0results = { displayFieldName: null, features: [] };
layer1results = { displayFieldName: null, features: [] };
for (var i = 0, il = idResults.length; i < il; i++) {
var idResult = idResults;
if (idResult.layerId === 7) {
if (!layer7results.displayFieldName) { layer7results.displayFieldName = idResult.displayFieldName };
layer7results.features.push(idResult.feature);
} else if (idResult.layerId === 3) {
if (!layer3results.displayFieldName) { layer3results.displayFieldName = idResult.displayFieldName };
layer3results.features.push(idResult.feature);
} else if (idResult.layerId === 4) {
if (!layer4results.displayFieldName) { layer4results.displayFieldName = idResult.displayFieldName };
layer4results.features.push(idResult.feature);
} else if (idResult.layerId === 2) {
if (!layer2results.displayFieldName) { layer2results.displayFieldName = idResult.displayFieldName };
layer2results.features.push(idResult.feature);
} else if (idResult.layerId === 0) {
if (!layer0results.displayFieldName) { layer0results.displayFieldName = idResult.displayFieldName };
layer0results.features.push(idResult.feature);
} else if (idResult.layerId === 1) {
if (!layer1results.displayFieldName) { layer1results.displayFieldName = idResult.displayFieldName };
layer1results.features.push(idResult.feature);
}
}
dijit.byId("layer7Tab").setContent(layerTabContent(layer7results, "layer7results", evt.mapPoint));
dijit.byId("layer3Tab").setContent(layerTabContent(layer3results, "layer3results", evt.mapPoint));
dijit.byId("layer4Tab").setContent(layerTabContent(layer4results, "layer4results", evt.mapPoint));
dijit.byId("layer2Tab").setContent(layerTabContent(layer2results, "layer2results", evt.mapPoint));
dijit.byId("layer0Tab").setContent(layerTabContent(layer0results, "layer0results", evt.mapPoint));
dijit.byId("layer1Tab").setContent(layerTabContent(layer1results, "layer1results", evt.mapPoint));
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
} I am getting an error that dijit.byId("layer7Tab") is not defined. Any ideas? Thanks
... View more
10-24-2012
06:26 AM
|
1
|
0
|
597
|
POST
|
Actually sorted it! // Position our mapto the x and y provided in the url var point = new esri.geometry.Point([x, y], new esri.SpatialReference({ wkid: map.spatialReference.wkid })); //var point = esri.geometry.Point(new esri.geometry.Point(x, y)); console.log("Zooming to location..."); map.centerAndZoom(point, zoomLevel); console.log("Zoom complete"); this is not documented anywhere (that i found on the site!! might be wrong!) the fix was adding the spatial ref to the point!
... View more
10-04-2012
07:58 AM
|
0
|
0
|
235
|
POST
|
Hi My code below. I am having issues when i have added a dynamic map service to my code. When the map zooms into the x/y specified, i get a 404 error on the dynamic map service - http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer/export?dpi=96&transparent=true&format=png8&layers=show%3A0%2C1%2C2%2C5%2C6&bbox=349519.8477901956%2C328478.0609601219%2C353292.1522098044%2C330017.9390398781&bboxSR=null&imageSR=null&size=1901%2C776&f=image stating that the bboxSR is invalid (i have noticed the imageSR is null aswell) When i then pan on the map, the dynamic service works an is visual on the map. - http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer/export?dpi=96&transparent=true&format=png8&layers=show%3A0%2C1%2C2%2C5%2C6&bbox=347974.0165735332%2C327450.1526543053%2C351746.32099314197%2C328990.03073406144&bboxSR=27700&imageSR=27700&size=1901%2C776&f=image . It seems its something to do with when the map loads and it zooms to the location, the dynamic service does not seem to know the SR! I have tried to set it manually using imageParameters however this failed. Please any help with this as in kinda stuck at the moment. cheers <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>CRM Mapping Testing</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" type="text/css" href="http://sw08agsd/DEV/css/map_new.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar { padding: 20px 20px; } #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=3.1"></script> <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="http://sw08agsd/DEV/js/identify.js"></script> <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery.stylish-select.min.js"></script> <!-- jquery plugin --> <script type="text/javascript" src="http://sccw08ags/DEV/js/jquery/jquery.url.packed.js"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); // Required for identify dojo.require("esri.tasks.identify"); dojo.require("esri.layers.FeatureLayer"); dojo.require("dijit.Toolbar"); dojo.require("dijit.layout.TabContainer"); //old tab "identify" box dojo.require("dijit._Widget"); //additional parameters for editing widgets dojo.require("dojox.layout.TableContainer"); dojo.require("esri.arcgis.utils"); dojo.require("dijit.form.CheckBox"); dojo.require("dijit.layout.AccordionContainer"); </script> <script type="text/javascript"> var symbol; var map; var graphic; var mapLayers = []; //var visible = []; var layer7results, layer3results, layer4results, layer2results, layer0results, layer1results; var setSymbol, setSymbol1, setSymbol2, setSymbol3, setSymbol4, setSymbol5, setSymbol6; var highlight_id1 = [], highlight_id2 = [], highlight_id3 = [], highlight_id4 = [], highlight_id5 = [], highlight_id6 = []; function init() { var initExtent = new esri.geometry.Extent({ "xmin": 186819, "ymin": 230984, "xmax": 506529, "ymax": 407263, "spatialReference": { "wkid": 27700 } }); map = new esri.Map("map", { extent: initExtent }); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://sccw08ags/ArcGIS/rest/services/CABackground_Greyscale/MapServer"); //var imageParameters = new esri.layers.ImageParameters(); //ImageParameters.imagespatialReference = new esri.SpatialReference({ wkid: 27700}); //imageParameters.imageSpatialReference = "27700"; //imageParameters.format = "png8"; //imageParameters.imageSpatialReference = new esri.SpatialReference({wkid:27700}); //console.log(imageParameters.imageSpatialReference); var lbsr = new esri.layers.ArcGISDynamicMapServiceLayer("http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer", { "opacity": 0.7 //"imageParameters": imageParameters }); map.addLayer(basemap); //console.log(map.geometry.Extent.spatialReference.wkid); //mapLayers.push(basemap); //mapLayers.push(lbsr); // When dojo has received notification that everything's been loaded, we'll run an "anonymous function" dojo.connect(map, 'onLoad', function () { dojo.connect(dijit.byId('map'), 'resize', map, map.resize); var urlObject = esri.urlToObject(document.location.href); // Set our default position, zoom level and layerid's var x = 351406; var y = 329248; var zoomLevel = 8; var layers = [0,1,2,3,4,5,6,7,8,9]; // Do we have a qeury string on the URL? if (urlObject.query) { // Do we have a coords parameter? if (urlObject.query.coords) { var coords = urlObject.query.coords.split(','); // We have an x and a y right? if (coords.length == 2) { x = parseFloat(coords[0]); y = parseFloat(coords[1]); console.log(x); console.log(y); } } // Let's check for a zoomlevel if (urlObject.query.zoomLevel) { zoomLevel = parseInt(urlObject.query.zoomLevel); console.log(zoomLevel); } //Let's check if any layers are specified if (urlObject.query.layers) { //layers = parseInt(urlObject.query.layers); layers = urlObject.query.layers.split(','); console.log(layers); } //set the visable layers that where passed in the url lbsr.setVisibleLayers(layers); } // Position our mapto the x and y provided in the url var point = esri.geometry.Point(new esri.geometry.Point(x, y)); map.centerAndZoom(point, zoomLevel); // Highlight the item on our map if (!graphic) { addGraphic(point); } else { graphic.setGeometry(point); } map.centerAt(point); setUpIdentify(layers); }); //adds an image to the x and y that was passed function addGraphic(point) { var symbol = new esri.symbol.PictureMarkerSymbol('http://sw08agsd/DEV/img/marker-icon.png', 20, 30); graphic = new esri.Graphic(point, symbol); map.graphics.add(graphic); } map.addLayer(lbsr); } dojo.addOnLoad(init); </script> </head> <body class="claro"> <span id="layer_list"></span> <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="border:1px solid #000;padding:0;"></div> </div> <div id="tabs" dojoType="dijit.layout.AccordionContainer"> <div id="layer7Tab" dojoType="dijit.layout.ContentPane"></div> <div id="layer2Tab" dojoType="dijit.layout.ContentPane"></div> <div id="layer1Tab" dojoType="dijit.layout.ContentPane"></div> <div id="layer3Tab" dojoType="dijit.layout.ContentPane"></div> <div id="layer4Tab" dojoType="dijit.layout.ContentPane"></div> <div id="layer0Tab" dojoType="dijit.layout.ContentPane"></div> </div> </body> </html>
... View more
10-03-2012
07:52 AM
|
0
|
2
|
648
|
POST
|
yep working url here http://sccw08ags/ArcGIS/rest/services/APILBSR/MapServer/export?dpi=96&transparent=true&format=png8&layers=show%3A0%2C2%2C3%2C5%2C7&bbox=350098.6249894166%2C328579.59501735674%2C352190.1604224875%2C329639.25338667346&bboxSR=27700&imageSR=27700&size=1581%2C801&f=image as you can see the bboxSR and imageSR have both been populated correctly... I cant seem to replicate this any other time besides when the initial map loads. Got the params working though, so cheers if ( urlObject.query.layers ){
layers = parseInt(urlObject.query.layers);
var layers = urlObject.query.layers.split(',');
console.log (layers);
}
then on the map service -
layer.setVisibleLayers(layers);
... View more
10-01-2012
07:41 AM
|
0
|
0
|
286
|
Title | Kudos | Posted |
---|---|---|
1 | 10-24-2012 06:26 AM | |
1 | 07-09-2017 08:13 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|