小编Bra*_*row的帖子

限制将Google Maps V3标记拖动到折线

我创建了一个谷歌地图并在其上绘制了折线.然后我在polyine的起点添加了一个标记(与折线的起始坐标相同的坐标).

我希望能够做的是抓住并拖动标记,但让它"粘"到折线上,这样你只能沿着折线拖动它而不是远离它或者它的侧面.

是否可以将可拖动标记限制在GM V3的路径中?如果没有,有谁能想到如何做到这一点?当用户放下标记时,有可能将标记捕捉到路径上最近的点,但我更喜欢更顺畅的"沿路径拖动"效果.

很高兴有ArcGis的建议.没有提供代码,因为这更像是一个理论问题.

如果我需要进一步解释,请告诉我.

提前致谢

arcgis draggable google-maps-markers google-polyline

13
推荐指数
1
解决办法
4566
查看次数

Jquery.get()在IE8/9中不起作用.不会加载未修改的缓存页面304

Code Igniter版本'2.0.3'Jquery 1.7 Jquery History插件

嗨,大家好,

我有一个CodeIgniter应用程序,我以ajax方式构建.我有如下功能:

$(document).on('click','.ajax_link',function(e){
    //Stop the normal href action
    e.preventDefault();

    //Grab the destination URL
    var new_url = $(this).attr('href')

    //Grab the content via ajax and pass it to the history change function
    $.get(base_url+new_url,function(data){
        History.pushState({
            content:data.content,
            url:data.url
        }, data.title, data.url);
        //Refresh some site variables
        refresh();
    },'json');
});
Run Code Online (Sandbox Code Playgroud)

它只是通过一个ajax_link类捕获对锚元素的点击,并将响应发送到一个处理该响应数据放入页面的函数.

这适用于Chrome和FF.我点击链接,jQuery发出get请求,我得到一个JSON对象,我的history.pushState()函数将一些json数据注入我的页面.

我遇到的问题是在IE8中.基本上发生的事情是当我第一次打开应用程序时,链接可以工作,但它们只能工作一次.我第二次点击链接:

  • 是ajax GET
  • 收到304(未修改)的回复
  • 不调用jQuery.get()回调函数,因此停止死机.

如果我清除缓存它再次工作.所以我的假设是IE正在执行get请求,但后来它发现它已经在过去请求了完全相同的文件...因此完全停止了该过程.

有人知道解决这个问题吗?我已经看过在IE中提到304错误和ajax和缓存的错误但是还没有找到与我相同的问题.

任何帮助非常感谢

(在Windows虚拟机IE8和Internet Explorer 9中的IE 8模式上测试)

解决了

只需要将以下代码添加到我的document.ready函数中,问题就消失了.

$.ajaxSetup ({cache: false});
Run Code Online (Sandbox Code Playgroud)

ajax jquery caching internet-explorer-8 http-status-code-304

7
推荐指数
1
解决办法
5064
查看次数

单元测试AngularJS控制器,其资源使用$ routeParams

注意:我在CoffeeScript中编写所有内容

我有一个控制器如下:

angular.module('myApp').controller 'MyController', ($scope, $routeParams, Batch) ->
    $scope.$on '$routeChangeSuccess', () ->
        Batch.get {batchUuid: $routeParams.batchUuid}, (response) ->
            $scope.batch_id = response.id
Run Code Online (Sandbox Code Playgroud)

控制器提取Batch资源,该资源定义如下:

angular.module('myApp').factory 'Batch', ($resource) ->
    $resource '/batches/:batchUuid', {}
Run Code Online (Sandbox Code Playgroud)

我有一个这样的路线如下:

$routeProvider.when('/batches/:batchUuid',
    { templateUrl: 'batches-processing.html', controller: 'MyController' })
Run Code Online (Sandbox Code Playgroud)

所以:

  • 您访问路线/批次/ 22
  • 它使用MyController
  • 它会触发$ routeChangeSuccess
  • 它调用了来自路由的batchUuid的批处理资源
  • 它返回一个json响应并为$ scope.batch_id分配一个id

现在我想测试这个,所以我有一个单元测试如下:

describe 'Controllers', ->
    beforeEach module 'myApp'
        describe 'MyController', ->
            scope = {}
            ctrl= {}

            beforeEach inject ($rootScope, $controller, Batch, $httpBackend) ->
                scope = $rootScope.$new()
                ctrl = $controller('MyController', ($scope: scope))
                #I imagine I …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing jasmine angularjs

7
推荐指数
1
解决办法
5707
查看次数

Phonegap 1.5(Cordova)ios childbrowser根本不打开

我是一个完整的Phonegap新手,所以如果可以的话,请放轻松我:)

我已经安装了phonegap 1.5并且运行正常.我努力安装childbrowser插件,但我相信它现在已正确安装.但是,我似乎无法让儿童浏览器显示出来?我尝试过这里的各种教程(http://bit.ly/ifK9lM)和这里(http://bit.ly/wOlq6k).我没有遇到任何构建错误或控制台错误,但是当我点击链接时,子浏览器才显示.

当我点击我的按钮时,我进入控制台的所有内容都是"打开网址:http://www.google.com ".所以就好像它正在尝试......但我没有得到视觉输出?

我在我的www文件夹的根目录下的cordova.js文件中有ChildBrowser.js文件.我将所有Child浏览器插件文件添加到xcode中的插件文件夹中.

我正在使用Xcode 3.2.6

如果有人能够建议我做错了什么,那将非常感激.

我不能在这里发布所有相关代码,因为它只是失控.很高兴发布请求的代码.

这是我目前的appdelegate.h文件:

#import "AppDelegate.h"
#import "MainViewController.h"

#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVURLProtocol.h>
#else
#import "CDVPlugin.h"
#import "CDVURLProtocol.h"
#endif

#import "ChildBrowserCommand.h"
#import "ChildBrowserViewController.h"

@implementation AppDelegate

@synthesize invokeString, window, viewController;

//Code excluded for brevity here.....

#pragma UIWebDelegate implementation

- (void) webViewDidFinishLoad:(UIWebView*) theWebView 
{
// only valid if FooBar.plist specifies a protocol to handle
if (self.invokeString)
{
    NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
    [theWebView …
Run Code Online (Sandbox Code Playgroud)

plugins xcode3.2 ios cordova

6
推荐指数
1
解决办法
5271
查看次数