Community
All Communities
Products
ArcGIS Pro
ArcGIS Survey123
ArcGIS Online
ArcGIS Enterprise
Data Management
ArcGIS Experience Builder
Geoprocessing
ArcGIS Web AppBuilder
ArcGIS Dashboards
ArcGIS Field Maps
ArcGIS StoryMaps
All Products Communities
Industries
Education
Water Resources
State & Local Government
Transportation
Gas and Pipeline
Water Utilities
Roads and Highways
Telecommunications
Natural Resources
Electric
Imagery and Remote Sensing Insights (IRIS) COP
All Industries Communities
Developers
Python
JavaScript Maps SDK
Native Maps SDKs
ArcGIS API for Python
ArcGIS Pro SDK
ArcObjects SDK
Developers - General
ArcGIS REST APIs and Services
ArcGIS Online Developers
Game Engine Maps SDKs
File Geodatabase API
All Developers Communities
Global
Comunidad Esri Colombia - Ecuador - Panamá
ArcGIS 開発者コミュニティ
Czech GIS
ArcNesia
Europe
Esri India
Americas
Asia Pacific
Comunidad GEOTEC
GeoDev Germany
ArcGIS Content - Esri Nederland
All Global Communities
All Communities
Developers
User Groups
Industries
Services
Community Resources
Global
Events
Learning
Networks
ArcGIS Topics
Products
View All Communities
ArcGIS Ideas
GIS Life
Community Resources
Community Help Documents
Community Blog
Community Feedback
Member Introductions
All Community Resources
Sign In
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show
only
|
Search instead for
Did you mean:
Cancel
Home
:
All Communities
:
Developers
:
JavaScript Maps SDK
:
JavaScript Maps SDK Questions
:
My added point is in BFE
Options
Subscribe to RSS Feed
Mark Topic as New
Mark Topic as Read
Float this Topic for Current User
Bookmark
Subscribe
Mute
Printer Friendly Page
Select to view content in your preferred language
Translate Now
My added point is in BFE
Subscribe
765
2
07-26-2012 01:34 PM
by
JohnCorrea
Emerging Contributor
07-26-2012
01:34 PM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Well not necessarily Bum Effing Egypt but 200 km south of Ghana. This means that my points coordinates are at 0. But why?
Here is my code.
dojo.require("dijit.dijit");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.arcgis.utils");
dojo.require("esri.dijit.Legend");
dojo.require("esri.dijit.Scalebar");
esri.config.defaults.geometryService = new esri.tasks.GeometryService('
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
var map;
var x = eval('@Model.Longitude'), y = eval('@Model.Latitude');
function init() {
var mapid = "61b91bd7159d4712ac50988e5fd7d4c7"
var mapDeferred = esri.arcgis.utils.createMap(mapid, "map", {
mapOptions: {
slider: true,
nav: false
}
});
mapDeferred.addCallback(function (response) {
map = response.map;
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
//add the legend
if (map.loaded) {
addPointToMap( x, y );
}
else {
dojo.connect(map, "onLoad", function () {
addPointToMap(x, y);
});
}
});
mapDeferred.addErrback(function (error) {
console.log("Map creation failed: ", dojo.toJson(error));
});
}
function addPointToMap(lon, lat) {
var point = new esri.geometry.Point(parseFloat(lon), parseFloat(lat), new esri.SpatialReference({ wkid: 4326 }));
var symbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 255, 0]));
var graphic = new esri.Graphic(point, symbol);
map.graphics.add(graphic);
}
dojo.ready(init);
</script>
<div id="map" style="width: 650px; height: 600px; border: 1px solid #000;">
</div>
Tags
(2)
Tags:
javascript
web_developers
Reply
0
Kudos
All Posts
Previous Topic
Next Topic
2 Replies
by
StephenLead
Honored Contributor
07-26-2012
04:01 PM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Assuming that your map is in Web Mercator projection, you probably need to re-project your points from decimal degrees.
See the
geographicToWebMercator
help doco.
Steve
Reply
0
Kudos
by
JohnCorrea
Emerging Contributor
07-27-2012
07:38 AM
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Yep, that did it.
It was as simple as wrapping the new point definition in this function:
var point = esri.geometry.geographicToWebMercator(
new esri.geometry.Point(lon, lat, new esri.SpatialReference({ wkid: 4326 }))
);
Thank you sir!
Reply
0
Kudos
Post Reply