Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. i want to get LatLng based on textbox value.

i want to get LatLng based on textbox value.

Scheduled Pinned Locked Moved ASP.NET
javascriptcomiottoolsjson
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Ya Rasoolallah
    wrote on last edited by
    #1

    hello i want to get LatLng (in google map) based on the textbox value. what do i do? i have an error when run this cod: the error is:

    Microsoft JScript runtime error: Object required

    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
    </script>

    <script type="text/javascript">
    var a=parseInt(document.getElementById("Text1").value);
    var b=parseInt(document.getElementById("Text2").value);

    var myCenter=new google.maps.LatLng(a,b);
    function initialize()
    {
    var mapProp = {
    center:myCenter,
    zoom:15,
    mapTypeId:google.maps.MapTypeId.ROADMAP
    };
    var map=new google.maps.Map(document.getElementById("googleMap")
    ,mapProp);
    var marker=new google.maps.Marker({
    position:myCenter,
    animation:google.maps.Animation.BOUNCE
    });

    marker.setMap(map);

    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>

    <input id="Text1" type="text" value="36"/>
    <input id="Text2" type="text" value="59"/>

    P 1 Reply Last reply
    0
    • Y Ya Rasoolallah

      hello i want to get LatLng (in google map) based on the textbox value. what do i do? i have an error when run this cod: the error is:

      Microsoft JScript runtime error: Object required

      <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
      </script>

      <script type="text/javascript">
      var a=parseInt(document.getElementById("Text1").value);
      var b=parseInt(document.getElementById("Text2").value);

      var myCenter=new google.maps.LatLng(a,b);
      function initialize()
      {
      var mapProp = {
      center:myCenter,
      zoom:15,
      mapTypeId:google.maps.MapTypeId.ROADMAP
      };
      var map=new google.maps.Map(document.getElementById("googleMap")
      ,mapProp);
      var marker=new google.maps.Marker({
      position:myCenter,
      animation:google.maps.Animation.BOUNCE
      });

      marker.setMap(map);

      }

      google.maps.event.addDomListener(window, 'load', initialize);
      </script>

      <input id="Text1" type="text" value="36"/>
      <input id="Text2" type="text" value="59"/>

      P Offline
      P Offline
      Peter Leow
      wrote on last edited by
      #2

      There are a few mistakes, 1. myCenter is not initialized 2. LatLng should be float type not integer type 3. there should be a function that is activated by say a button click in order to capture the new a and b values upon changes by the user 4. a and b have to be converted to latlng type 5. Spot the rest yourself from my demo code below:

      <!DOCTYPE html>
      <html>
      <head>
      <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
      </script>

      <script>
      var a;
      var b;
      var map;

      var myCenter=new google.maps.LatLng(a,b);
      function initialize()
      {
      a=parseFloat(document.getElementById("Text1").value);
      b=parseFloat(document.getElementById("Text2").value);
      var myCenter= new google.maps.LatLng(a, b);
      var mapProp = {
      center:myCenter,
      zoom:8,
      mapTypeId:google.maps.MapTypeId.ROADMAP
      };
      map=new google.maps.Map(document.getElementById("googleMap")
      ,mapProp);
      var marker=new google.maps.Marker({
      position:myCenter,
      animation:google.maps.Animation.BOUNCE
      });

      marker.setMap(map);

      }

      function updateLocation(){
      a=parseFloat(document.getElementById("Text1").value);
      b=parseFloat(document.getElementById("Text2").value);

      var latLng = new google.maps.LatLng(a, b); //create a latlng
      map.panTo(latLng); //Make map global

      }

      google.maps.event.addDomListener(window, 'load', initialize);
      </script>
      </head>
      <body>
      <input id="Text1" type="text" value="1.3520830"/>
      <input id="Text2" type="text" value="103.819836"/>
      <button onclick="updateLocation()">Update Location</button>
      <div id="googleMap" style="width:800px;height:500px;"></div>
      </body>
      </html>

      Y 1 Reply Last reply
      0
      • P Peter Leow

        There are a few mistakes, 1. myCenter is not initialized 2. LatLng should be float type not integer type 3. there should be a function that is activated by say a button click in order to capture the new a and b values upon changes by the user 4. a and b have to be converted to latlng type 5. Spot the rest yourself from my demo code below:

        <!DOCTYPE html>
        <html>
        <head>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
        </script>

        <script>
        var a;
        var b;
        var map;

        var myCenter=new google.maps.LatLng(a,b);
        function initialize()
        {
        a=parseFloat(document.getElementById("Text1").value);
        b=parseFloat(document.getElementById("Text2").value);
        var myCenter= new google.maps.LatLng(a, b);
        var mapProp = {
        center:myCenter,
        zoom:8,
        mapTypeId:google.maps.MapTypeId.ROADMAP
        };
        map=new google.maps.Map(document.getElementById("googleMap")
        ,mapProp);
        var marker=new google.maps.Marker({
        position:myCenter,
        animation:google.maps.Animation.BOUNCE
        });

        marker.setMap(map);

        }

        function updateLocation(){
        a=parseFloat(document.getElementById("Text1").value);
        b=parseFloat(document.getElementById("Text2").value);

        var latLng = new google.maps.LatLng(a, b); //create a latlng
        map.panTo(latLng); //Make map global

        }

        google.maps.event.addDomListener(window, 'load', initialize);
        </script>
        </head>
        <body>
        <input id="Text1" type="text" value="1.3520830"/>
        <input id="Text2" type="text" value="103.819836"/>
        <button onclick="updateLocation()">Update Location</button>
        <div id="googleMap" style="width:800px;height:500px;"></div>
        </body>
        </html>

        Y Offline
        Y Offline
        Ya Rasoolallah
        wrote on last edited by
        #3

        thank you very much muhammad I say condolence for the suffering of martyrdom the prophet Mohammad and the Imam Hasan and the Imam Reza to all of the Muslims.:rose::rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups