My program has a center point and one moving object . At this moment this point is somewhere in Europe.But Now i have to change that point from the latitude and longitude values(of Australia) . Please see This program . from that program i could make program running .


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;
using SharpMap.Layers;
using SharpMap.Data;
using SharpMap.Styles;
using SharpMap.Rendering.Thematics;
using BruTile.Web;
using WindowsFormsApplication1.Properties;

#if DotSpatialProjections
using GeometryTransform = DotSpatial.Projections.GeometryTransform;
using GeometryTransform = GeoAPI.CoordinateSystems.Transformations.GeometryTransform;

namespace WindowsFormsApplication1
    public partial class FormMovingObjectOverTileLayer : Form

        private List<IGeometry> geos = new List<IGeometry>();

        private bool movingUp = true;
        private bool movingLeft = true;
        GeoAPI.Geometries.Coordinate position;

        public FormMovingObjectOverTileLayer()
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)

#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            var geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform.Source, mathTransform.Target);

            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform);


            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");

            var gf = new GeometryFactory(new PrecisionModel(), 3857);

            //Adds a static layer
            var staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            var aux = new List<IGeometry>();

            staticLayer.Style.Symbol = Resources.PumpSmall;
            var geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux);
            staticLayer.DataSource = geoProviderFixed;

            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            position = geom.Centre;

            pushPinLayer.Style.Symbol = Resources.ZoomToExtents1;

            var geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);
            pushPinLayer.DataSource = geoProvider;


        private void timer1_Tick(object sender, EventArgs e)
            double dx, dy;
            if (movingLeft)
                dx = -100;
                dx = 100;

            if (movingUp)
                dy = 100;
                dy = -100;

            position.X = position.X + dx;
            position.Y = position.Y + dy;

            if (position.X < this.mapBox1.Map.Envelope.MinX)
                movingLeft = false;
            else if (position.X > this.mapBox1.Map.Envelope.MaxX)
                movingLeft = true;

            if (position.Y < this.mapBox1.Map.Envelope.MinY)
                movingUp = true;
            else if (position.Y > this.mapBox1.Map.Envelope.MaxY)
                movingUp = false;



        private void button4_Click(object sender, EventArgs e)
            this.timer1.Enabled = true;

        private void button1_Click(object sender, EventArgs e)
            this.timer1.Enabled = false;

        private void Form2_SizeChanged(object sender, EventArgs e)

        private void FormMovingObjectOverTileLayer_FormClosing(object sender, FormClosingEventArgs e)

  • That's a lot of code to read through. Are you getting specific error messages? Is there a particular problem in this code that needs addressing? The first thing I notice is Envelope(-9.205626, -9.123736, 38.690993, 38.740837) is not in Australia... apart from that WGS84 Web Mercator is worldwide. spatialreference.org/ref/sr-org/7483 – Michael Stimson Sep 8 '15 at 2:01
  • @MichaelMiles-Stimson Thank Michael. There is no error the problem is how to convert latitude an longitude values to this format – newb Sep 8 '15 at 2:22
  • It should be the same. A coordinate from the GPS will probably be in WGS84/DD and you're transforming into Web Mercator, which works the same way in Europe, Asia, U.S... everywhere. North and South Poles might be a little distorted though. – Michael Stimson Sep 8 '15 at 2:25

It looks like you're using DotSpatial.

Here's a similar question and answer: Coordinate transformation/reprojection using DotSpatial

This looks like the documentation for the library: http://www.mapwindow.org/downloads/documentation/dotspatial-1.0/html/66de9da3-2eda-7ca5-9ee5-e9b8a76f8392.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.