Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to display map icons for a number of different locations, where the latitude and longitude is stored in a sql database. How can I approach this?

What I have tried:

Tried hardcoding and that works, but I need to do it from a database.
Posted
Updated 14-Aug-18 7:43am
Comments
ZurdoDev 14-Aug-18 8:16am    
Find a mapping tool.
SQL has a lot of built-in functions to work with coordinates; although, I have never used them.
F-ES Sitecore 14-Aug-18 8:49am    
Change your hard-coded coordinates for coordinates from the database. Until we know what mapping system you are using and what database access technology yo are using it won't be possible to give concrete advice.
Member 13685517 14-Aug-18 16:19pm    
i am using bing map portal, for the project

1 solution

I will give you a vague answer, as all I know is are using C#, some flavor of SQL, and an unknown display medium.

For the SQL portion, I will use a minimal table structure
SQL
CREATE TABLE dbo.Locations (
  LocID   INT IDENTITY(1,1) NOT NULL,
  locName NVARCHAR(100)		NULL,	-- Location Name
  LocLat  DECIMAL(9,6)		NULL,	-- Latitude
  LocLng  DECIMAL(9,6)		NULL,	-- Longitude
  CONSTRAINT [PK_Locations_ID] PRIMARY KEY CLUSTERED([LocID] ASC) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT Locations( LocName, LocLat, LocLng)
VALUES  ('Los Angeles', 34.05223, -118.24368)
,       ('Santa Monica', 34.02421, -118.49647)
,       ('Redondo Beach', 33.84918, -118.38840)
,       ('Newport Beach', 33.62834, -117.92793)
,       ('Long Beach', 33.77005, -118.19373)
GO


The next 2 parts will be in C#; first a POCO
C#
CREATE TABLE dbo.Locations (
	public int LocID
	public string LocName
	public double LocLat
	public double LocLng
}


And the second will be population
// write your own code, but here are the highlights

string cmd = "SELECT LocName, LocLat, LocLng FROM Locations"
// create DataReader and use above to populate
// return Collection<Locations> from above DataReader


Last thing is to display this. Without knowing how you intend to do this all I can tell is to just pass the above collection and iterate through it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900